Skip to content

Commit ddac11f

Browse files
authored
Merge pull request #165 from srivastava9/master
Automatic email sender made
2 parents 8d7026e + c1ae3a2 commit ddac11f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import sys
2+
import smtplib
3+
4+
# For different email option choose different server domain name
5+
# for Gmail - smtp.gmail.com
6+
# for Yahoo Mail - smtp.mail.yahoo.com
7+
# for Outlook.com - smtp-mail.outlook.com
8+
9+
email = smtplib.SMTP("smtp.gmail.com", 587) # for SSL encryption use port 465
10+
email.ehlo()
11+
email.starttls() # skip this line if using SSL encryption
12+
recipients = []
13+
subject = input("Enter your Email's subject\n")
14+
email_body = input("Enter your Email's body\n")
15+
number_of_reciever = int(input("Enter number of receiver's\n"))
16+
for i in range(number_of_reciever):
17+
recipients.append(input("reciever " + str(i + 1) + "'s email-id\n"))
18+
19+
my_email = input("Enter your email-id\n")
20+
my_password = input("Enter you password\n")
21+
try:
22+
email.login(my_email, my_password)
23+
except:
24+
print(
25+
'Your email id or password is wrong \n google is not allowing you to log in via smtplib because it has flagged this sort of login as "less secure" so what you have to do is go to this link while you\'re logged in to your google account, and allow the access: https://www.google.com/settings/security/lesssecureapps \n'
26+
)
27+
for i in range(number_of_reciever):
28+
email.sendmail(my_email, recipients[i], "Subject:" + subject + "\n" + email_body)
29+
print("Your emails are sent :)")
30+
email.quit()

0 commit comments

Comments
 (0)