-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_email.py
More file actions
43 lines (33 loc) · 1.16 KB
/
send_email.py
File metadata and controls
43 lines (33 loc) · 1.16 KB
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
40
41
42
43
import smtplib
# for simple message transfer protocol
import getpass
# to share to, from, subject, body info
from email.mime.text import MIMEText
def send_mail():
senders_addr = "emailID"
# to get password from user
password = getpass.getpass()
subject = 'Machine Learning Session'
msg = '''
Hello Everyone,
This is Lissa from Oracle. Here is the announcement of next meetup.
Timing 11AM on 22nd aug, Friday.
Thank you,
Shreya Kajbaje
'''
# SERVER INITIALIZATION
# enable smtp server for connection smtp.gmail.com is the host and its port is by default 587
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
# tls is the handshake which allows the connection
# to login
server.login(senders_addr, password)
recipients = ['emailID_1', 'emailID_2']
# DRAFT MESSAGE BODY
msg = MIMEText(msg)
msg['Subject'] = subject
msg['From'] = senders_addr
msg['To'] = ", ".join(recipients)
# msg.set_param('importance', 'high value')
server.sendmail(senders_addr, recipients, msg.as_string())
send_mail()