Failing to send email with the Python example

后端 未结 10 939
南旧
南旧 2020-12-04 15:56

I\'ve been trying (and failing) to figure out how to send email via Python.

Trying the example from here: http://docs.python.org/library/smtplib.html#smtplib.SMTP

10条回答
  •  情深已故
    2020-12-04 16:26

    import smtplib
    
    content = 'example email stuff here'
    
    mail = smtplib.SMTP('smtp.gmail.com', 587)
    
    mail.ehlo()
    
    mail.starttls()
    
    mail.login('email@gmail.com','password')
    
    mail.sendmail('email@gmail.com', 'email@yahoo.com', content)
    
    mail.close()
    

提交回复
热议问题