GithubHelp home page GithubHelp logo

aerendir / bundle-aws-ses-monitor Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 6.0 1.71 MB

Symfony Bundle to manage AWS SES notifications through AWS SNS.

Home Page: http://aerendir.me

License: MIT License

PHP 99.65% Shell 0.29% Ruby 0.06%
aws-ses sns symfony email swiftmailer php symfony-bundle

bundle-aws-ses-monitor's Introduction

Serendipity HQ AWS SES Monitor Bundle

AWS SES Monitor Bundle automates the filtering of bounced and complained e-mails sent through AWS SES.

Supports:

Supports:

Current Status

Coverage Maintainability Rating Quality Gate Status Reliability Rating Security Rating Technical Debt Vulnerabilities

Phan PHPStan PSalm PHPUnit Composer PHP CS Fixer Rector

Features

AWS SES can give you notifications about bounced or complained e-mails both via e-mail or via the AWS SNS service.

Managing these notifications it is possible to know to which e-mails we should not send further e-mails.

This bundle helps you setting up the automatic handling of notifications via SNS.


Do you like this bundle?
LEAVE A ★

or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!


How AWS SES Monitor Bundle integrates with AWS SNS

Using AWS SES Monitor Bundle you can, using the console of your Symfony's App, create in AWS Simple Notifications Service a topic for bounced emails and one for complained emails and automatically subscribe your app identity to that topics.

The bundle exposes some endpoints called by AWS Simple Email Service when an e-mail is bounced or complained. When those endpoints are called, AWS SES Monitor Bundle persists these emails in the database.

The SwiftMailer plugin included reads these e-mails and automatically disable the sending of e-mails to those addresses.

The entire procedure is automated by the bundle in a really simple and easy way.

Documentation

You can read how to install, configure, test and use AWS SES Monitor Bundle in the documentation.


Do you like this bundle?
LEAVE A ★

or run
composer global require symfony/thanks && composer thanks
to say thank you to all libraries you use in your current project, this included!


bundle-aws-ses-monitor's People

Contributors

aerendir avatar dependabot-preview[bot] avatar dependabot[bot] avatar foaly-nr1 avatar kodiakhq[bot] avatar povilas avatar shivas avatar tacman avatar v-popovski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bundle-aws-ses-monitor's Issues

[aws:ses:monitor:subscribe] Make possible to configure topics with --no-interaction

This way is possible to call the command on each deploy to test if all works well.

Think better at this: the main goal is to be sure the integration with AWS SES works as expected each time the app is deployed.

For example, check the app can connect to AWS.

Make also possible to automatically subscribe all not already subscribed identities.

See also #42.

Dispatch some events

Hey,

It would be nice to dispatch some events about bounces, complaints so that we can subscribe to make extra treatments in our app.

Regards

Rename "Deliveries.enabled" into "track"

The enabled param is not sufficiently clear: rename it to track to make clear its purpose is to enable tracking also of the delivered emails.

The same for complaints and bounces.

Add to Symfony Flex

https://github.com/symfony/recipes-contrib

  • Create a config file in config/packages/shq_aws_ses_monitor.yaml with this content:
# Aws Ses Monitor
shq_aws_ses_monitor:
    aws_config:
        credentials_service_name: 'Aws\Credentials\Credentials'
        region: '%env(AWS_REGION)%'
    bounces:
        topic:
            name: '%env(AWS_SES_TOPIC_BOUNCES)%'
            endpoint:
                protocol: '%env(APP_SCHEME)%'
                host: '%env(APP_HOST)%'
    complaints:
        topic:
            name: '%env(AWS_SES_TOPIC_COMPLAINTS)%'
            endpoint:
                protocol: '%env(APP_SCHEME)%'
                host: '%env(APP_HOST)%'
    deliveries:
        topic:
            name: '%env(AWS_SES_TOPIC_DELIVERIES)%'
            endpoint:
                protocol: '%env(APP_SCHEME)%'
                host: '%env(APP_HOST)%'
  • Create a config file in config/packages/dev/shq_aws_ses_monitor.yaml with this content:
# Aws Ses Monitor
shq_aws_ses_monitor:
    bounces:
        topic:
            endpoint:
                protocol: '%env(NGROK_APP_SCHEME)%'
                host: '%env(NGROK_APP_HOST)%'
    complaints:
        topic:
            endpoint:
                protocol: '%env(NGROK_APP_SCHEME)%'
                host: '%env(NGROK_APP_HOST)%'
    deliveries:
        topic:
            endpoint:
                protocol: '%env(NGROK_APP_SCHEME)%'
                host: '%env(NGROK_APP_HOST)%'
  • Add those variables to .env file:
    • NGROK_APP_SCHEME
    • NGROK_APP_HOST
    • AWS_SES_VERSION
    • AWS_SES_TOPIC_BOUNCES
    • AWS_SES_TOPIC_COMPLAINTS
    • AWS_SES_TOPIC_DELIVERIES

Other variables used, but not only by AwsSesMonitorBundle
- AWS_SNS_VERSION
- AWS_ACCESS_KEY_ID
- AWS_ACCESS_KEY_SECRET
- AWS_REGION

As on

Only allow to configure the scheme and host for the endpoint

Currently the bundle requires a configuration like this:

# Aws Ses Monitor
shq_aws_ses_monitor:
    aws_config:
        credentials_service_name: 'Aws\Credentials\Credentials'
        region: '%env(AWS_REGION)%'
    bounces:
        topic:
            name: '%env(AWS_SES_TOPIC_BOUNCES)%'
            endpoint:
                protocol: '%env(APP_SCHEME)%'
                host: '%env(APP_HOST)%'
    complaints:
        topic:
            name: '%env(AWS_SES_TOPIC_COMPLAINTS)%'
            endpoint:
                protocol: '%env(APP_SCHEME)%'
                host: '%env(APP_HOST)%'
    deliveries:
        topic:
            name: '%env(AWS_SES_TOPIC_DELIVERIES)%'
            endpoint:
                protocol: '%env(APP_SCHEME)%'
                host: '%env(APP_HOST)%'

This is verbose and not useful.

Maybe a configuration like this is better:

# Aws Ses Monitor
shq_aws_ses_monitor:
    aws_config:
        credentials_service_name: 'Aws\Credentials\Credentials'
        region: '%env(AWS_REGION)%'
    topics:
        endpoint:
            protocol: '%env(APP_SCHEME)%'
            host: '%env(APP_HOST)%'
    bounces:
        # Remove
        topic:
            name: '%env(AWS_SES_TOPIC_BOUNCES)%'
    complaints:
        # Remove
        topic:
            name: '%env(AWS_SES_TOPIC_COMPLAINTS)%'
    deliveries:
        # Remove
        topic:
            name: '%env(AWS_SES_TOPIC_DELIVERIES)%'
            endpoint:
                protocol: '%env(APP__OTHER_SCHEME)%'
                host: '%env(APP_OTHER_HOST)%'

This way is the configuration is way more simple.

[aws:ses:configure] Create the command

Goal: avoid to subscribe, for example, coommercio.com from trustback.me.

In development only email like [email protected] can be subscribed. Maybe can be useful to make this email configurable (dev.test_identity).

This requires #82

Todos:

  • Configure on SES Identities configured in bundle:
  • Check the topic is not already subscribed
  • Topic is subscribed to identities
  • App is subscribed to topic
  • Based on configuration, make possible to enable or disable the inclusion of original headers in the SNS notification (SetIdentityHeadersInNotificationsEnabled);
  • Based on configuration, make possible to enable or disable the email feedback forwarding (SetIdentityFeedbackForwardingEnabled);
  • Check differences for dev env and prod env: on dev should not be possible to subscribe to domain identities, but only to the email identity [email protected] (that has to be verified and work as expected to make possible to test the real sending of emails through SES in development). The test email can be configured: if changed, the debug command should highlight that the test email doesn't have the test mailbox.

This command will substitute the exsisting ones:

  • aws:ses:monitor:setup:bounces-topic
  • aws:ses:monitor:setup:complaints-topic
  • aws:ses:monitor:setup:deliveries-topic

[aws:ses:debug] Create the command

The command has to check that all is configured well.

This requires #82

Checks to do:

  • Account

    • The account is enabled for sending emails;
    • There still is quota available;
  • Identities: list all identities and for each one list:

    • Is Identity verified?
    • Is DKIM enabled?
    • Is DKIM verified?

Dispatch events on relevant events

Events that will be dispatched:

  • Recipient filtered out (before sending);
  • Recipient filtered out (after sending);
  • Bounce notification from AWS SES;
  • Complaint notification from AWS SES;
  • Delivery notification from AWS SES;

Requested in #31

Rename protocol config param to scheme

Rename

  • shq_aws_ses_monitor.bounces.topic.endpoint.protocol to shq_aws_ses_monitor.bounces.topic.endpoint.scheme
  • shq_aws_ses_monitor.complaints.topic.endpoint.protocol to shq_aws_ses_monitor.complaints.topic.endpoint.scheme
  • shq_aws_ses_monitor.deliveries.topic.endpoint.protocol to shq_aws_ses_monitor.deliveries.topic.endpoint.scheme

custom ORM model manager

Two issues when working with a custom entity manager:

In: aws-ses-monitor-bundle/Command/SnsSetupCommandAbstract.php

line 90 needs to be changed from:
$this->getContainer()->get('doctrine.orm.default_entity_manager')->flush();

to:
$this->getContainer()->get('aws_ses_monitor.entity_manager')->flush();

and line 181 from:
$this->getContainer()->get('doctrine.orm.default_entity_manager')->persist($topic);

to:
$this->getContainer()->get('aws_ses_monitor.entity_manager')->persist($topic);

Thanks!

Email statuses duplicated entry

Hey,

I have been getting few exceptions about duplicate entry in email statuses table. Any ideas?

An exception occurred while executing 'INSERT INTO aws_ses_monitor_email_statuses (hard_bounces_count, soft_bounces_count, last_bounce_type, last_time_bounced, complaints_count, last_time_complained, deliveries_count, last_time_delivered, email_address) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [0, 0, null, null, 0, null, 1, "2017-08-21 11:01:16", "[email protected]"]: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "aws_ses_monitor_email_statuses_pkey" DETALHE: Key (email_address)=([email protected]) already exists.

I am running Sf 2.8 with "serendipity_hq/aws-ses-monitor-bundle": "^1.2"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.