V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2016-01-07 23:43:16 +08:00 · 3359 次点击
    这是一个创建于 3038 天前的主题,其中的信息可能已经有所发展或是发生改变。

    大家好,我尝试使用 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  
       2016-01-08 02:20:37 +08:00
    试试 smtpobj.set_debuglevel(1) 以及 login 时开 initial_response_ok=True 我刚试了一下也是 Sina 发给 Aol 的, 成功了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   746 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:43 · PVG 05:43 · LAX 14:43 · JFK 17:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.