Search code examples
pythonamazon-web-servicesamazon-s3boto3amazon-ses

AWS SES Add Custom Headers to the mail


I am trying to send email with AWS SES which,the raw email will be put in the S3, on file lambda will trigger and parse customer headers.

Example:

see picture

How can i add custom headers like X-moto-dealerId : 4324

    client = boto3.client('ses')
response = client.send_email(
    Source=email_from,
    Destination={
        'ToAddresses': [email_to]
    },
    Message={
        'Subject': {
            'Data': 'string',
            'Charset': 'UTF-8'
        },
        'Body': {
            'Text': {
                'Data': generated_adf,
                'Charset': 'UTF-8'
            }
        }

    },

)

Solution

  • You need to use the send_raw_email function of boto3 instead of send_email.

    Some additional sources of information: