-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils.py
More file actions
23 lines (18 loc) · 693 Bytes
/
utils.py
File metadata and controls
23 lines (18 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from email.mime.text import MIMEText
import email.utils
import smtplib
FROM_EMAIL = "tfi@checkmein.site"
FROM_NAME = "TFI CheckMeIn"
def sendEmail(toName, toEmail, subject, message, ccName="", ccEmail=""):
msg = MIMEText(message)
msg['To'] = email.utils.formataddr((toName, toEmail))
if ccEmail:
msg['Cc'] = email.utils.formataddr((ccName, ccEmail))
msg['From'] = email.utils.formataddr((FROM_NAME, FROM_EMAIL))
msg['Subject'] = subject
try: # pragma: no cover
server = smtplib.SMTP('localhost')
server.sendmail(FROM_EMAIL, [toEmail], msg.as_string())
server.quit()
except IOError:
print('Email would have been:', msg)