我已经检查了代码,并确保我的凭据正确无误。我不断收到如下错误:
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
任何帮助将不胜感激:)
这是代码:
import smtplib
def EmailSender():
##try:
server=smtplib.SMTP(host='smtp.gmail.com', port=465)
server.starttls()
server.login("my gmail email","my gmail password")
msg=MIMEMultipart()
message=message_template.substitute(NAME=name.title())
msg['From']=MYADDR
msg['To']=SENDTO
msg['Subject']="Testing functionality of Python is sometimes painstaking, but when you see that message come through, it's well worth it :)"
msg.attatch(MIMEText(message, 'plain'))
server.send_message(msg)
##except:
## print("There was an error esablishing a connection...")
EmailSender()