File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ # importing the module
2+
3+ import smtplib
4+
5+ sender_add = "sender123@gmail.com"
6+ receiver_add = "reciver789@gmail.com"
7+ password = "password"
8+
9+ # creating the SMTP server object by giving SMPT server address and port number
10+
11+ smtp_server = smtplib .SMTP ("smtp.gmail.com" , 587 )
12+ smtp_server .ehlo () # setting the ESMTP protocol
13+
14+ smtp_server .starttls () # setting up to TLS connection
15+ smtp_server .ehlo () # calling the ehlo() again as encryption happens on calling startttls()
16+
17+ smtp_server .login (sender_add , password )
18+
19+ msg_to_be_sent = """
20+ Hello, receiver!
21+ Hope you are doing well.
22+ Welcome to PythonGeeks!
23+ """
24+
25+ # sending the mail by specifying the from and to address and the message
26+
27+ smtp_server .sendmail (sender_add , receiver_add , msg_to_be_sent )
28+ print ("Successfully the mail is sent" ) # priting a message on sending the mail
29+
30+ smtp_server .quit ()
You can’t perform that action at this time.
0 commit comments