[英]Email is not being sent. Please tell the problem?
Please tell the error in the code.请告诉代码中的错误。 Output is always "Email not sent"
输出总是“电子邮件未发送”
import smtplib
port = 587
sender_mail = input("Enter your email address : ")
sender_password = input("Enter your password : ")
receiver_mail = input("Enter receiver's mail address : ")
message = input("Enter the message you want to send ")
try:
server = smtplib.SMTP("smtp.gmail.com",port)
server.starttls()
server.login(sender_mail,sender_password)
server.sendmail(sender_mail,receiver_mail,message)
print("Email sent successfully")
server.quit()
except:
print("Email not sent")
server.quit()
Change your except:
, to get exception text更改您的
except:
,以获取异常文本
try:
#Your code
except Exception as e:
print("Email not sent, Exception:", str(e))
server.quit()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.