2010-07-27 3 views
2

나는 python smtplib 및 xoauth를 사용하고 있으며 전자 메일을 보내려고합니다. 나는 구글에 의해 게시 된 코드를 사용하고 있습니다 : http://code.google.com/p/google-mail-xoauth-tools/source/browse/trunk/python/xoauth.pyGmail SMTP + XOAuth mystery

실제로 Gmail에 대해 인증하고를하고 난 예상대로 내 XOAUTH 문자열을 보낸 후이 응답

reply: '235 2.7.0 Accepted\r\n' 

을 얻을 (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

에 있습니다.
관련 문제