-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathEmail sender.py
More file actions
30 lines (28 loc) · 776 Bytes
/
Email sender.py
File metadata and controls
30 lines (28 loc) · 776 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
import smtplib
# Before executing, go to-
# gmail->account->security->less secure apps->turn on access
print("----- Email sender -----")
# sender mail
sender_mail = input("- Enter your mail --> ")
# receiver mail
receiver_mail = input("- Enter receiver's mail --> ")
# message
message = """From : From mail
To : To mail
Subject : test mail
If you dont use gmail, u boomer.
""" % (
sender_mail,
receiver_mail,
)
try:
# password
password = input("- Enter your password --> ")
smtpobj = smtplib.SMTP("smtp.gmail.com", 587)
smtpobj.login(sender_mail, password)
smtpobj.sendmail(sender_mail, receiver_mail, message)
# positive case
print("- Successfully sent email.")
except Exception:
# negative case
print("- Unable to send email!")