File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import smtplib
2+
3+ host = "smtp.gmail.com"
4+ port = 587
5+ username = "hungrypy@gmail.com"
6+ password = "iamhungry2016"
7+ from_email = username
8+ to_list = ["hungrypy@gmail.com" ]
9+
10+ email_conn = smtplib .SMTP (host , port )
11+ email_conn .ehlo ()
12+ email_conn .starttls ()
13+ email_conn .login (username , password )
14+ email_conn .sendmail (from_email , to_list , "Hello there this is an email message" )
15+ email_conn .quit ()
16+
17+
18+ from smtplib import SMTP
19+
20+
21+ ABC = SMTP (host , port )
22+ ABC .ehlo ()
23+ ABC .starttls ()
24+ ABC .login (username , password )
25+ ABC .sendmail (from_email , to_list , "Hello there this is an email message" )
26+ ABC .quit ()
27+
28+
29+ from smtplib import SMTP , SMTPAuthenticationError , SMTPException
30+
31+
32+ pass_wrong = SMTP (host , port )
33+ pass_wrong .ehlo ()
34+ pass_wrong .starttls ()
35+ try :
36+ pass_wrong .login (username , "wrong_password" )
37+ pass_wrong .sendmail (from_email , to_list , "Hello there this is an email message" )
38+ except SMTPAuthenticationError :
39+ print ("Could not login" )
40+ except :
41+ print ("an error occured" )
42+
43+ pass_wrong .quit ()
44+
45+
46+
You can’t perform that action at this time.
0 commit comments