Skip to content

Commit 783a732

Browse files
authored
Create sendEmail.py
1 parent 6f8e99d commit 783a732

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Python/sendEmail.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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()

0 commit comments

Comments
 (0)