forked from skol-1/pet-it-up
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailing.py
34 lines (26 loc) · 782 Bytes
/
mailing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import smtplib
import config_mail as config
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send(reciver,message):
sender = config.MAIL_USERNAME
password = config.MAIL_PASSWORD
msg = MIMEMultipart()
msg['From'] = sender
msg['To'] = reciver
msg['Subject'] = 'Petitup | Confirmation Link'
body = message
msg.attach(MIMEText(body,'plain'))
# creates SMTP session
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login(sender, password)
# message to be sent
text = msg.as_string()
# sending the mail
s.sendmail(sender,reciver, text)
# terminating the session
s.quit()
return