iT邦幫忙

0

在Python如何取得SMTP伺服器回應

請問使用Python內建的SMPT物件,如何取得SMTP伺服器回應的訊息,我的寫法如下:

try:
...     import smtplib
...     smtpObj = smtplib.SMTP(mail_host, 587)
...     a = smtpObj.starttls()
...     smtpObj.set_debuglevel(1)
...     b = smtpObj.login(mail_user, mail_pass)
...     c = smtpObj.sendmail(sender, receivers, message.as_string())
...     d = smtpObj.quit()
...     print("Success")
... except smtplib.SMTPException as e:
...     print("Error: QQ......")
...     print(e)

但如圖所示,即使信件因為SMTP的限制無法寄出,仍是沒有觸發例外;另外變數c與d也沒有收到任何東西。
我要如何知道我的郵件是否真的被成功寄出貨是失敗?
我使用的服務:https://support.google.com/a/answer/2956491#sendinglimitsforrelay
https://ithelp.ithome.com.tw/upload/images/20200314/2008839518ceBjq0AG.jpg

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
Ray
iT邦大神 1 級 ‧ 2020-03-14 17:52:09

......(抱歉, 我回錯篇).....

/images/emoticon/emoticon01.gif

黃彥儒 iT邦高手 1 級 ‧ 2020-03-15 10:35:33 檢舉

還想說雷大出手,這題穩了/images/emoticon/emoticon36.gif

尼克 iT邦大師 1 級 ‧ 2020-03-16 09:15:55 檢舉

/images/emoticon/emoticon01.gif

我要發表回答

立即登入回答