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
durden
V2EX  ›  Python

有没有办法让Python调用Gmail中的'Send Email As'设置信息来发送邮件

  •  
  •   durden · 2012-09-04 23:58:49 +08:00 · 3497 次点击
    这是一个创建于 4223 天前的主题,其中的信息可能已经有所发展或是发生改变。
    情况是这样的,利用Python的smtplib可以很轻松的实现自动通过Gmail SMTP服务器发送邮件(如下),Gmail中有个‘Send Email As’的设置,可以用‘他人’的身份来发送邮件,我就想是在脚本中调用该设置,即用非Gmail而是经过Gmail验证的其他邮箱地址将这个邮件发出去(这个目标邮箱是exchange server邮箱,我在脚本中无法直接连接...),不知道是否可以呢?



    import smtplib

    fromaddr = ''
    toaddrs = '[email protected]'
    msg = 'testing'

    username = 'usr'
    password = 'pwd'

    server = smtplib.SMTP('smtp.gmail.com:587')
    server.starttls()
    server.login(username,password)
    server.sendmail(fromaddr, toaddrs, msg)
    server.quit()
    1 条回复    1970-01-01 08:00:00 +08:00
    durden
        1
    durden  
    OP
       2012-09-05 09:20:13 +08:00
    anyone can help?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2803 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:50 · PVG 22:50 · LAX 07:50 · JFK 10:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.