Python: Email problem -


I am using the script below to send an email to myself, the script does not run properly with any errors, but I do not physically receive an email

  import smtplib this = 'foo@hotmail.com' receiver = ['foo@hotmail.com'] Message = "" "From: Person: To & lt; foo@hotmail.com & gt; To: person & lt; foo@hotmail.com> Subject: SMTP e-mail test This is a test e-mail message "" "Try: smtpObj = smtplib .SMTP ('local host ') SmtpObj.sendmail (Sender, receiver, message) "Successfully sent email" except SMTPException: "Error: Unable to send email"  

edit

script Named test.py

Why you use Lokhost as SMTP Are you

If you are using Hotmail, you have to use Hotmail account, provide password, port and SMTP server etc.

Here's what you are doing:

Edit: Here's an example I'm using Gmail:

  def (to be mailed to) (Subject, text) : msg = MIMEMultipart () msg ​​['from'] = gmail_user msg [to '' to '] = msg [[application', 'octet section' ) Encoders.encode_base64 (part) msg.attach (part) mailServer = smtplib.SMTP ("smtp.gmail] theme msg.attach (MimeText (text)) part = MIMEBase = '.com", 587) mailServer.ehlo () MailServer.starttls () mailServer.loglo () mailServer.login (gmail_user, gmail_pwd) mailServer.sendmail (to gmail_user, msg.as_string ()) should be # mailServer.quit (), but that Ras is ... mailServer.close ()  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -