I'm trying to send email through AWS SES, but I'm receiving this error:
botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the SendEmail operation: Illegal address
I already verified the email I'm sending to and from. This is my code:
import boto3 client = boto3.client( 'ses', aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY ) response = client.send_email( Destination={ 'ToAddresses': [ '[email protected]', ], }, Message={ 'Body': { 'Html': { 'Charset': 'UTF-8', 'Data': 'This message body contains HTML formatting. It can, for example, contain links like this one: <a class="ulink" href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide" target="_blank">Amazon SES Developer Guide</a>.', }, 'Text': { 'Charset': 'UTF-8', 'Data': 'This is the message body in text format.', }, }, 'Subject': { 'Charset': 'UTF-8', 'Data': 'Test email', }, }, ReplyToAddresses=[ ], ReturnPath='', ReturnPathArn='', Source='[email protected]', SourceArn='', )
How can I fix this?
A message placed in a spam folder indicates that Amazon SES has successfully delivered the message to the recipient's mail server (ISP). At this stage, Amazon SES has no control over the message and can't guarantee inbox placement.
The "Email address is not verified" error occurs for 2 reasons: We are trying to send emails, from identities (email or domain) that are not verified in AWS SES. The AWS SES account is in sandbox mode in that particular region.
Open the Amazon SES console at https://console.aws.amazon.com/ses/ . In the left navigation pane, under Configuration, choose Verified identities. In the list of identities, choose the identity you want to configure where the Identity type is Email address and Status is Verified.
Try to remove the following:
ReplyToAddresses=[], ReturnPath='', ReturnPathArn='', SourceArn='',
Apparently they can't be empty!
Although it isn't applicable to this question, in my case, I was trying to send emails to multiple addresses at the same time.
Having a single email address here helped.
'ToAddresses': [ '[email protected]', ],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With