Python,没有收到邮件

时间:2017-07-17 07:28:24

标签: python email smtplib

我正在使用smtplib发送邮件,但邮件既没有发送也没有收到错误。代码如下:

    import smtplib
    import textwrap
    from email.mime.text import MIMEText

    msg = {}
    msg['From'] = 'me@mydomain.me'
    msg['To'] = 'yours@gmail.com'
    msg['Subject'] = "This is TEST"
    TEXT = 'HAY BUDDY'

    server = smtplib.SMTP('mail.mydomain.me', 26)
    server.login("user@mydomain.me", "xxx")
    message = textwrap.dedent("""\
        From: %s
        To: %s
        Subject: %s
        %s
        """ % (msg['From'], msg['To'], msg['Subject'], TEXT))

    print(message)
    server.sendmail(msg['From'], msg['To'], message)
    server.quit()

0 个答案:

没有答案