I have checked over the code and made sure that my credentials are correct but to no avail. I keep getting an error that looks like this:
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Any help would be appreciated :)
Here's the code:
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()