出於某種原因,下面的代碼不能正確設置主題字段,並且肯定不會在HTML中呈現電子郵件......即收到電子郵件時,標籤不再出現。python smtp沒有設置主題/ html
謝謝!
def sendEmail (self,remove):
message = """From: From Postmaster <%s>
To: To Person <%s>
MIME-Version: 1.0
Content-type: text/html
Subject: blahblah
<b>This is HTML message.</b>
<h1>The following email addresses have been removed</h1>
%s
""" %(self.sender,self.receivers,remove)
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(self.sender, self.receivers, message)
print "Successfully sent email"
應該有頭和消息體之間的空行。你有沒有理由不包括?它對你的問題有什麼不同嗎? – SingleNegationElimination 2012-01-02 21:09:19