Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29767

Send Raw Email (with attachment) to Multiple Recipients

$
0
0

I am currently using Python 2.7 and trying to send a raw email with an attachment (CSV to be exact) to multiple addresses with Boto SES. I can send a normal email with send_email(), but I keep getting an error when trying to send to multiple people via send_raw_email().

This is the error that I get with a comma-separated string of recipients:

Error sending email: SESIllegalAddressError: 400 Illegal address<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/"><Error><Type>Sender</Type><Code>InvalidParameterValue</Code><Message>Illegal address</Message></Error><RequestId>[the request ID]</RequestId></ErrorResponse>

That's from using this code:

to_emails = "me@example.com, them@example.com"# create raw emailmsg = MIMEMultipart()msg['Subject'] = 'Email subject'msg['From'] = 'me@example.com'msg['To'] = to_emailspart = MIMEText('Attached is an important CSV')msg.attach(part)part = MIMEApplication(open(fname, 'rb').read())part.add_header('Content-Disposition', 'attachment', filename=fname)msg.attach(part)# end create raw emailconn = boto.ses.connect_to_region('[my region]',    aws_access_key_id=s3_access_key,     aws_secret_access_key=s3_secret_key    )conn.send_raw_email(msg.as_string(),    source=msg['From'],    destinations=msg['To']    )

Also, here is the error I get from using an array of strings for recipients:

Error sending email: 'list' object has no attribute 'lstrip'

It works fine if I have just one recipient, so it just throws the error when I have an array of recipients and a comma-separated string of recipients. Anyone have any experience with this?


Viewing all articles
Browse latest Browse all 29767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>