Hello all,
I am trying to send an email after a script completes. The email successfully sends but the To, From, and Subject of the email are all blank. Additionally, the "To" email that gets put into the body of the email has commas after every letter.
Code I am using is below. Any ideas?
fromaddr: 'from@from.com' #example only
toaddrs: 'test@email.com' #example only
subject = 'SUBJECT TEXT'
mailtext = 'EMAIL BODY TEXT'
msg = """\
From: %s
To: %s
Subject: %s
%s
""" % (fromaddr, ", ".join(toaddrs), subject, mailtext)
server = smtplib.SMTP('111.111.111.111') #sample IP
if "Connection information provided was for a non-administrative user" in msg:
server.sendmail(fromaddr, toaddrs , msg)
else:
server.sendmail(fromaddr, toaddrs, msg)
server.quit()