aerendir / bundle-aws-ses-monitor Goto Github PK
View Code? Open in Web Editor NEWSymfony Bundle to manage AWS SES notifications through AWS SNS.
Home Page: http://aerendir.me
License: MIT License
Symfony Bundle to manage AWS SES notifications through AWS SNS.
Home Page: http://aerendir.me
License: MIT License
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"
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:
SesClient::VerifyEmailAddress()
and SesClient::VerifyDomainIdentity()
);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
In the documentation, the examples of configuration should now use ENV
s as this is the new way of setting parameters.
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.
https://github.com/symfony/recipes-contrib
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)%'
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)%'
.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
Make possible to see relevant information directly from the app front-end, using SonataAdmin.
Goal: avoid to subscribe the same topic from development and production.
As on
Remove badges from README.md
Remove connection with CodeShip (on codeship and in GitHub)
Configure Travis-ci to test with both versions of Symfony and PHP.
Implement also other suggestions from best practices: Continuous integration.
As on
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
See also #41.
Events that will be dispatched:
Requested in #31
See also #40.
It is not clear in the documentation the purpose of the parameter.
The command has to check that all is configured well.
This requires #82
Checks to do:
Account
Identities: list all identities and for each one list:
This requires phpstan/phpstan#1203 to be solved.
Then reactivate also the tests oh Phan
.
[ ] Add query string param that is used as password
;
[ ] Check if it is possible to verify the request really comes from Amazon.
As on Aerendir/bundle-stripe#2
The command is meant to unsubscribe a topic from a notification type.
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.
This will allow for more precise checks about subscriptions
As suggested by Best practices: Tests.
As on
https://docs.aws.amazon.com/sns/latest/dg/json-formats.html#http-header
x-amz-sns-message-type = UnsubscribeConfirmation
Relevant code in HandlerFactory::buildHandler()
.
As recommended by best practices: Directory structure.
Instead of requiring them to be added to the Doctrine's configuration.
See also #44.
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!
As suggested by best practices: Documentation.
As on
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
The AWS SNS has a MailObject
part.
Save it into the database.
See: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/notification-contents.html#mail-object
The corresponding identity has to be already verified or can be also not still verified?
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.
As recommended by best practices: Service Format: YAML
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.