【问题标题】:Gmail SMTP + XOAuth mysteryGmail SMTP + XOAuth 之谜
【发布时间】:2013-01-10 08:22:18
【问题描述】:

我正在使用 python smtplib 和 xoauth,我正在尝试发送电子邮件。 我正在使用谷歌发布的代码:http://code.google.com/p/google-mail-xoauth-tools/source/browse/trunk/python/xoauth.py

我实际上是在对 Gmail 进行身份验证,我收到了这个回复

reply: '235 2.7.0 Accepted\r\n'

按预期发送我的 XOAuth 字符串后 (http://code.google.com/apis/gmail/oauth/protocol.html#smtp)

当我尝试发送电子邮件时,我收到以下错误

reply: '530-5.5.1 Authentication Required. Learn more at                              
reply: '530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 f10sm4144741bkl.17\r\n'

有什么线索吗?

【问题讨论】:

    标签: python oauth gmail smtplib


    【解决方案1】:

    问题在于您如何进行 SMTP 连接,这是我的代码中的一个 sn-p:

        smtp_conn = smtplib.SMTP('smtp.googlemail.com', 587)
        #smtp_conn.set_debuglevel(True)
        smtp_conn.ehlo()
        smtp_conn.starttls()
        smtp_conn.ehlo()
        smtp_conn.docmd('AUTH', 'XOAUTH ' + base64.b64encode(xoauth_string))
    

    您按照 Google 的示例创建 xoauth_string。之后,您可以使用 smtp_conn 发送您的电子邮件。如果您有任何问题,请告诉我。你可以在https://github.com/PanosJee/xoauth找到一些示例代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-13
      • 2011-07-10
      • 2011-12-26
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      • 2011-04-16
      相关资源
      最近更新 更多