SMTPエラー:(552、 '5.6.0の提出拒否
-
29-09-2019 - |
質問
リレーサーバーを介して電子メールを送信するためのPythonスクリプトを書きました。 Telnetを使用して電子メールを送信することにより、適切なメールアドレスなどが許可されているなどをテストしました。私のPythonスクリプトは、古いリレーサーバーを介して送信するように設定されたときにも機能します。
したがって、私はなぜ私が次のエラーメッセージを受け取っているのかについて混乱しています:
(552, '5.6.0 Submission denied Sender does not match originator <myEmailAddress>)
SMTPエラー552を調べましたが、メッセージサイズを超えていることが原因ですが、サイズがわずか数kbのHTMLの数行を含むメールを送信しているので、安全に支配できると仮定しています。この問題。
何が問題になるのかという他のアイデアはありますか?
編集:エラーを生成するPythonコードを次に示します。
1 #!/usr/bin/env python
2 import sys
3 from sys import argv
4 import smtplib
5 import logging
6 import logging.handlers
7
8 LOG_FILENAME = 'sendMail.log'
9 inputMessage = argv[1]
10 sender = 'hi@sender.com'
11 receivers = 'hi@sender.com'
12 #Reads in the file as a single string
13 message = open(inputMessage, 'r').read()
14 log = logging.getLogger()
15
16 def initializelogging():
17 log.setLevel(logging.DEBUG)
18 fileformatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
19 filehandler = logging.handlers.RotatingFileHandler(
20 LOG_FILENAME,
21 maxBytes=10000000,
22 backupCount=100)
23 filehandler.setFormatter(fileformatter)
24 consoleformatter = logging.Formatter('%(levelname)s: %(message)s')
25 consolehandler = logging.StreamHandler()
26 consolehandler.setLevel(logging.INFO)
27 consolehandler.setFormatter(consoleformatter)
28 log.addHandler(filehandler)
29 log.addHandler(consolehandler)
30 initializelogging()
31
32 def sendMail():
33 try:
34
35 smtpObj = smtplib.SMTP('mailserver@server.com')
36 smtpObj.sendmail(sender,sender, message)
37 print "Successfully sent email"
38 log.info('Successfully sent email')
39 except Exception, err:
40 log.error('Unable to send email. See below stack trace........')
41 log.error('%s\n' % str(err))
42 sendMail()
解決
これらのいずれかがエラーの実際の原因であることを保証することはできませんが、:
私 考える あなたが得ているメッセージは、それを言っているかもしれません
From:
メッセージのヘッダーは、送信者に使用している電子メールアドレスと一致しませんsendmail()
電話。ファイルから読んでいるメッセージa)有効なsmtpヘッダーがあることを確認してください(少なくともFrom
,To
, 、 とSubject
, 、 とMIME-Version
とContent-Type
傷つけないだろう)そしてもっと具体的にはb)From: hi@sender.com
ヘッダ。SMTPオブジェクトのインスタンス化は、電子メールアドレスではなくサーバーアドレスを取得します。使用する必要があります
smtpObj = smtplib.SMTP('mail.server.com')
またはそんなにない何か他のもの@
初期化。それ以外の場合、それはあなたが思うサーバーに接続していない可能性があります。