0
我有python程序發送郵件給用戶。雖然有些用戶無法獲得郵件,但我們也沒有收到任何錯誤消息。即使我向未知(無效)電子郵件地址發送郵件,該程序也不會顯示任何錯誤。通過Python程序成功發送郵件,但用戶無法收到郵件
以下是我的程序。
class SendEmail:
def __init__(self, smtpserver, smtpuser, smtppass, smtpport):
self.smtpserver = smtpserver
self.smtpuser = smtpuser
self.smtppass = smtppass
self.smtpport = smtpport
def send(self, to_list, subject, html):
msgRoot = MIMEMultipart('ralated')
msgRoot['Subject'] = subject
msgRoot['From'] = self.smtpuser
print ";".join(to_list)
msgRoot['To'] = ";".join(to_list)
msgRoot.preamble = 'This is a multi-part message in MIME format.'
msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)
msgText = MIMEText(html, 'html', 'utf-8')
msgAlternative.attach(msgText)
try:
smtp = smtplib.SMTP(self.smtpserver,self.smtpport)
#smtp.connect(self.smtpserver)
#if self.smtppass != None:
# smtp.login(self.smtpuser, self.smtppass)
smtp.sendmail(self.smtpuser, to_list, msgRoot.as_string())
except smtplib.SMTPException,e:
print smtplib.SMTPException,":",e
smtp.quit()
sendm = SendEmail("###","####",None,25)
sendm.send(['[email protected]'],'ECOMM Error Testing','\
This is test email , Please let me know If you get the mail,many thanks!')
檢查您的郵件日誌! –
對不起,在哪裏檢查郵件日誌?似乎運行後沒有任何日誌返回smtp.sendmail(....) – maomifadacai
在郵件服務器 –