-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_email.py
More file actions
32 lines (21 loc) · 741 Bytes
/
send_email.py
File metadata and controls
32 lines (21 loc) · 741 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
30
31
32
import smtplib, ssl
from email.message import EmailMessage
def send_notification(text):
sender_email = "kevin.solartent@gmail.com" # Enter your address
receiver_email = "shiningsword@gmail.com" # Enter receiver address
password = "xoslletnbsqgbqtb"
msg = EmailMessage()
msg.set_content(text)
msg['Subject'] = 'Property found'
msg['From'] = sender_email
msg['To'] = receiver_email
# creates SMTP session
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login(sender_email, password)
# sending the mail
s.sendmail(sender_email, receiver_email, msg.as_bytes())
# terminating the session
s.quit()