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.75 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 Issues

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"

[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

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

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

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

[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?

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.

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!

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

[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.

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.