0
私のサーバーのいずれかでsendmailを使用してエラーレポートを送信しています。私は文字列に追加してこのレポートを作成しています。次にsendmailを使用して電子メールを送信します。ただし、sendmailは文字列のタブを認識しません。私はこれをどのように修正するのだろうと思っていますか?Sendmailがタブを解析していません
def sendMail(data):
sendmail_location = "/usr/sbin/sendmail" # sendmail location
p = os.popen("%s -t" % sendmail_location, "w")
p.write("From: %s\n" % "[email protected]")
p.write("To: %s\n" % "[email protected]")
p.write("Subject: the subject\n")
p.write(data)
status = p.close()
if status != 0:
print "Sendmail exit status", status
例列は次のようになります
data = "%d\t%s\t%s\n" % (count, message, message2)
「認識する」とはどういう意味ですか?それは電子メールからそれらを取り除いていますか?あなたが与えたコードが実際にタブを持っていないときは混乱します。データの "文字列の例"ですか? –
はい。私はsendMail(data)を送ります。ここでdataは入力文字列の例です。 – jmnwong