forked from AdeelaIslam/adeelaISecond.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendMail.py
More file actions
29 lines (22 loc) · 704 Bytes
/
sendMail.py
File metadata and controls
29 lines (22 loc) · 704 Bytes
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
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 16 11:38:27 2020
@author: Adeela Islam
"""
import smtplib
import config
def send_email(subject, msg):
try:
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(config.EMAIL_ADDRESS, config.PASSWORD)
message = 'Subject: {}\n\n{}'.format(subject, msg)
server.sendmail(config.EMAIL_ADDRESS, config.EMAIL_ADDRESS, message) #server.sendmail(fromaddr, toaddrs, msg)
server.quit()
print("Success: Email sent!")
except:
print("Email failed to send.")
subject = "Test subject"
msg = "Hello there, how are you today?"
send_email(subject, msg)