2010-07-27 389 views
2

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

我其实鉴别针对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' 

任何线索?

回答

3

的问题是你如何在这里做的SMTP连接是从我的代码片段:

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)) 

您创建xoauth_string在从谷歌的例子。之后,您可以使用smtp_conn发送您的电子邮件。如果您有任何问题,请告诉我。你可以在https://github.com/PanosJee/xoauth

找到一些示例代码