python - SMTP library: Dynamic email content -
i have sendmail()
method uses smtp send out emails.
def sendmail(toaddrs, msg): # set credentials username = auto_email_username password = auto_email_password print "message received in send mail message: " + msg # sending mail using google smtp server server = smtplib.smtp('smtp.gmail.com:587') server.starttls() server.login(username,password) try: server.sendmail(username, toaddrs, msg.as_string()) except: server.sendmail(username, toaddrs, msg) server.quit()
it accepts list of emails (toaddrs) , sends message receives (msg) emails. call method inside django
view.
now what's happening here is, whenever message sent dynamic content, concatenated string, empty emails. idea why happening?
the print statement prints proper concatenated string method receives emails empty.
Comments
Post a Comment