Metrics per recipient on Amazon SES

0

I'm using Amazon's Simple Email Service to send transactional emails. For this, I created a Python class that uses the AWS SDK for Python, Boto3.

One of the parameters of this class, recipients, represents a list of recipients who will receive the emails. I created a configuration set with the "ses: from-domain" auto-tag and established that collected metrics will be sent to the CloudWatch service.

With this setting, I can check the number of recipients who opened the emails, clicked on the contained links, or dealt with rendering failure, as per my interest. However, these values are presented in aggregate form.

I would like to know how:

  • Use the configuration set to collect metrics per recipient (email address);
  • How to integrate the established configuration into my email sending code or the HTML that constitutes the email. Since I currently use the auto-tag feature, which only needs to be specified which config set is being used.
  • Method for sending emails:

    def send_email(self, subject, charset="UTF-8"):
            """
            """
            # Create a new SES resource and specify a region.
            client = boto3.client('ses',region_name=self._aws_region)
    
            # Try to send the email.
            try:
                #Provide the contents of the email.
                response = client.send_email(
                    Destination={
                        'ToAddresses': self._recipient,
                    },
                    Message={
                        'Body': {
                            'Html': {
                                'Charset': charset,
                                'Data': self._html_content.getvalue(),
                            },
                        },
                        'Subject': {
                            'Charset': charset,
                            'Data': subject,
                        },
                    },
                    Source=self.sender,
                    # If you are not using a configuration set, comment or delete the
                    # following line
                    ConfigurationSetName="test",
                )
            # Display an error if something goes wrong. 
            except ClientError as e:
                print(e.response['Error']['Message'])
            else:
                print("Email sent! Message ID:"),
                print(response['ResponseMetadata']['RequestId'])
    
        
    asked by anonymous 16.05.2018 / 01:50

    0 answers