I am using python smtplib and xoauth and I am trying to send an email. I am using the code posted by Google: http://code.google.com/p/google-mail-xoauth-tools/source/browse/trunk/开发者_Go百科python/xoauth.py
I am actually authenticating against Gmail and i get this reply
reply: '235 2.7.0 Accepted\r\n'
after sending my XOAuth string as expected (http://code.google.com/apis/gmail/oauth/protocol.html#smtp)
When I compose an email I try to send I get the following error
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'
Any clue?
The problem is on how you do the SMTP connection here is a snippet from my code:
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))
You create the xoauth_string as in the example from Google. After that you can use smtp_conn to send your email. If you have any problems let me know. You can find some sample code at https://github.com/PanosJee/xoauth
精彩评论