forked from vinay-kumar99/Hactoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmailSender.py
25 lines (21 loc) · 963 Bytes
/
EmailSender.py
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
import smtplib
from email.message import EmailMessage
send_mail_to = ['[email protected]','[email protected]' ] # Mail Id's of persons to whom the mail is to be sent to
email_obj = EmailMessage()
email_obj['from'] = '{Senders Name/Username}'
email_obj['to'] = ', '.join(send_mail_to)
email['subject'] = input("Please enter the subject: ")
email.set_content(input("Please enter The content: \n\t"))
with smtplib.SMTP(host='smtp.gmail.com', port=587) as smtp:
smtp.ehlo()
smtp.starttls()
while True:
try:
mail_id = '[email protected]'
email_password = input("Please enter the password for " + mail_id + ":- ")
smtp.login(mail_id, email_password)
smtp.send_message(email_obj)
print("Done!!!")
break
except:
print("There was a problem while login try again or check if this application is allowed to use the mail services in your mail settings")