-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_mail.py
32 lines (24 loc) · 909 Bytes
/
send_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
def send_mail(recipient, subject, message):
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
username = "[email protected]"
password = "OMGWorkWork10!"
msg = MIMEMultipart()
msg['From'] = username
msg['To'] = recipient
msg['Subject'] = subject
msg.attach(MIMEText(message))
try:
print('sending mail to ' + recipient + ' on ' + subject)
mailServer = smtplib.SMTP('smtp-mail.outlook.com', 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(username, password)
mailServer.sendmail(username, recipient, msg.as_string())
mailServer.close()
except error as e:
print(str(e))
trial = 'Test\n Test\n How are you\n'
send_mail('[email protected]', 'JCSU Feed Report', 'May the force be with you.\n '+trial)