I am trying to send HTML email via python on a unix server. I need to use p.communicate for other reasons. I'd like not to change this code too much so I dont have to fix all the scripts that use this function.
What I am trying to do is send to multiple to_add. it works with one but not more. I've tring to_address as a list, a string with addresses separated by comma.
html = MIMEText("<html><body>"+content+"</body>", "html")
msg = MIMEMultipart("alternative")
msg['To'] = email.utils.formataddr(('Recipient', to_address))
msg['From'] = email.utils.formataddr(('Author', 'author@company'))
msg['Subject'] = subject
msg.attach(html)
p = Popen(["/usr/sbin/sendmail", "-f","author@company","-t"], stdin=PIPE)
p.communicate(msg.as_string())
works with
doesnt work with
"[email protected],[email protected]" ["[email protected]","[email protected]"]