0
這是我的代碼使用帶附件發送電子郵件(sample.txt的 - 測試文件),發送郵件在Python 3.X
,但我沒有收到任何郵件的和沒有錯誤的被拋出
我試圖發送沒有附件的郵件,它工作...
我在做什麼錯誤的附件部分?
def sendmail():
try:
#...
msg.body = "Hello Flask message sent from Flask-Mail"
with app.open_resource("sample.txt") as fp:
msg.attach("sample.txt", "text/plain", fp.read())
mail.send(msg)
except Exception as e:
raise e
return "Check Your Inbox !!!"
我認爲你的代碼看起來很好。嘗試移除「text/plain」,例如:msg.attach(「sample.txt」,fp.read())'或嘗試文件的完整路徑。 –