AWS SES Python Example

An example of using the AWS SDK for Python (Boto3) to send an email through Amazon SES could look like this:

import boto3
 
# Create an SES client
ses = boto3.client('ses')
 
# Define the email message and recipients
email_message = {
    'Subject': {'Data': 'Test Email'},
    'Body': {
        'Text': {'Data': 'This is a test email sent through Amazon SES.'}
    }
}
recipients = ['[email protected]']
 
# Send the email
response = ses.send_email(
    Source='[email protected]',
    Destination={'ToAddresses': recipients},
    Message=email_message
)
 
# Print the response
print(response)

This example sends an email with a simple text message and subject “Test Email” from “[email protected]” to “[email protected]” using the send_email method of the SES client. The response from SES is then printed, which includes information about the email such as the message ID.

Please note that before sending email you have to verify email address, domain or email address in SES. Also, you need to have access key and secret key to access SES service.

Please follow and like us:
Content Protection by DMCA.com