推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
huamihu
V2EX  ›  Python

Python smtplib 无法发送邮件

  •  
  •   huamihu · Jan 7, 2016 · 4467 views
    This topic created in 3935 days ago, the information mentioned may be changed or developed.

    大家好,我尝试使用 smtplib 库发送邮件, 所有链接都正确,但就是无法发送邮件,请问是怎么回事,(帐户名密码改了,代码不变)

    import smtplib

    smtpobj =smtplib.SMTP('smtp.sina.com', 587)

    smtpobj.ehlo()

    print(smtpobj.starttls())
    print(smtpobj.login('[email protected]','XXXX'))

    print(smtpobj.sendmail('[email protected]','[email protected]','Subject: Hi \nthis is a python test mail body text'))


    运行结果一切正常,可就是无法发送邮件, 新浪的 smtp 开关也是开着的

    (220, b'ready for tls')
    (235, b'OK Authenticated')
    {}


    staticor
        1
    staticor  
       Jan 8, 2016
    试试 smtpobj.set_debuglevel(1) 以及 login 时开 initial_response_ok=True 我刚试了一下也是 Sina 发给 Aol 的, 成功了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1640 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:24 · PVG 00:24 · LAX 09:24 · JFK 12:24
    ♥ Do have faith in what you're doing.