-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMail.py
39 lines (29 loc) · 854 Bytes
/
Mail.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
35
36
37
38
39
import smtplib
from Config import *
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
class Mail:
msg = MIMEMultipart('alternative')
msg['From'] = Config.mailuser
msg['To'] = Config.mailto
def __init__(self):
pass
def setRec(self, to):
self.to = to
def setSub(self, sub):
self.msg['Subject'] = sub
def setMsg(self, html):
html = MIMEText(html, 'html')
self.msg.attach(html)
def send(self):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.ehlo()
server.login(Config.mailuser, Config.mailpass)
server.sendmail(Config.mailuser, Config.mailto, self.msg.as_string())
server.quit()
pass
# m = Mail()
# m.setMsg('hello how are you?')
# m.send()