2012-01-19 18 views
0

を失敗した私は以下のようにメールやコードを送信するためにPythonスクリプトを書いた:のpython SMTP sendmailのTLSとは -

smtp = smtplib.SMTP(MYMAILSERVER, '587') 
try: 
    smtp.set_debuglevel(1) 
    smtp.ehlo() 
    if smtp.has_extn('STARTTLS'): 
     smtp.starttls() 
     smtp.ehlo() 
     smtp.login(MYLOGINNAME, PASSWORD) 
     smtp.sendmail(FROM, TO, CONTENT) 
finally: 
    smtp.quit() 

以下のように私はメッセージを得た:

...... 
data: (354, 'Start mail input; end with <CRLF>.<CRLF>') 
send: 'From: xxxx/r/nTo: yyy/r/nSubject: this is a email from tutong/r/n/r/nJust for test and pls ignore it!~_~\r\n.\r\n' 
reply: '550 5.7.1 Client does not have permissions to send as this sender\r\n' 
reply: retcode (550); Msg: 5.7.1 Client does not have permissions to send as this sender 
data: (550, '5.7.1 Client does not have permissions to send as this sender') 
send: 'rset\r\n' 
reply: '250 2.0.0 Resetting\r\n' 
reply: retcode (250); Msg: 2.0.0 Resetting 
send: 'quit\r\n' 
reply: '221 2.0.0 Service closing transmission channel\r\n' 
reply: retcode (221); Msg: 2.0.0 Service closing transmission channel 
Traceback (most recent call last): 
    File "mailsend.py", line 11, in <module> 
    smtp.sendmail('xxxx', 'yyy', 'From: xxxx/r/nTo: yyy/r/nSubject: this is a email from tutong/r/n/r/nJust for test and pls ignore it!~_~') 
    File "/usr/local/lib/python2.5/smtplib.py", line 699, in sendmail 
    raise SMTPDataError(code, resp) 
smtplib.SMTPDataError: (**550, '5.7.1 Client does not have permissions to send as this sender')** 

どのようにできました問題を解決するには? ありがとう

答えて

5

まあ、私はエラーがすべてそれを言うと思いますか?電子メールアドレスにバインドされた資格情報を使用します。しかし、あなたのFROM変数はあなたのアカウントがそうしなければならないと言います。今日は、昔は送信者として電子メールアドレスを使用することはできません。

これは当てはまりません。あなたはスペルをチェックしましたか?

+0

@ Niclasの答えに同意します。実際のメールクライアント(Thunderbirdなど)で同じ認証情報を使用している場合はどうなりますか? –

+1

その質問は1歳と同じです:) –