邮件发送

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了邮件发送相关的知识,希望对你有一定的参考价值。

def sendmail():
    import  smtplib
    from email.mime.text import MIMEText
    from email.utils import formataddr

    msg = MIMEText(‘邮件内容‘,‘plain‘,‘utf-8‘)
    msg[‘From‘] = formataddr([‘bob‘,‘[email protected]‘])
    msg[‘To‘] = formataddr(["走人",‘[email protected]‘])
    msg[‘Subject‘] = ‘主题‘

    server = smtplib.SMTP(‘smtp.163.com‘,25)
    server.login(‘[email protected]‘,‘邮箱密码‘)
    server.sendmail(‘[email protected]‘,[‘[email protected]‘],msg.as_string())
    server.quit()

sendmail()


本文出自 “Mr.Liang” 博客,请务必保留此出处http://liangml.blog.51cto.com/10852271/1855751

以上是关于邮件发送的主要内容,如果未能解决你的问题,请参考以下文章