
Howto: Amazon SES PHP mailer
Hello!
Today I’ll show you how to set up mass mailing through Amazon SES from scratch.
First you need to have an account in Amazon Web Services and an attached method of payment for the service. If you have it, we can safely start!
So, let's go to the console: https://console.aws.amazon.com . In the list of services we are looking for SES. Because we didn’t deal with SES before, we are greeted with a depressing inscription:

After all the registrations and confirmations that you are not a spammer, you will receive the minimum limits for sending:

Next, we need to indicate and confirm the address that will be indicated in the letters in the From field.
In the Verified Senders menu, look for the Verify a new sender button.

So, just a little remains. We must create an IAM user, give him the right to send mail and assign him a key pair. We go here: https://console.aws.amazon.com/iam .
We create a new group:

Call it:

In the security policy templates we find the ready-made Amazon SES Full Access template :

After that, Next, Next, Next and created a user group.
The next step is to create a user in the Users menu:

Create a user and immediately generate a key pair for him:

User created:

Save a couple of his keys:
Add the user to the group that was created before, thereby giving the user rights:

So, we have a couple of keys that are given the right to send letters to SES.
In order to validate Amazon SES as a mail list, add an SPF record to your domain:
v = spf1 include: amazonses.com? All
Next, copy files to ourselves from the github.com/korjik/PHP-SES-mailer
ses.php repository - a class for connecting to SES - www.orderingdisorder.com/aws/ses
users.csv - an example of a list of users in the format
“username”, “ username@email.com »
send_email.php - the mail distribution program itself.
In send_email.php, you need to replace the following parameters:
Key pair:
$ ses = new SimpleEmailService (' Access Key Id ', ' Secret Access Key ');
Validated From address:
$ m-> setFrom (' validated@email.com ');
Next, fill in 2 text fields - the variables $ text_email and $ html_email with names are responsible for themselves.
If the preparations are done, the script can be run with the path parameter to the users.csv file:
$ php send_email.php users.csv
All users specified in users.csv will receive emails.
Do not use a valid From address from foreign domains. Lack of SPF records increases the chance of emails getting into spam.
As you noticed, we can insert a username, read as $ username = $ user_fields [0] from the CSV file , into each letter . Thus, you yourself can change the CSV format, add custom fields, etc.
If you have questions, write, I will answer.
Threat. The article is written specifically for Mr. m31 .
Today I’ll show you how to set up mass mailing through Amazon SES from scratch.
First you need to have an account in Amazon Web Services and an attached method of payment for the service. If you have it, we can safely start!
SES setup
So, let's go to the console: https://console.aws.amazon.com . In the list of services we are looking for SES. Because we didn’t deal with SES before, we are greeted with a depressing inscription:
After all the registrations and confirmations that you are not a spammer, you will receive the minimum limits for sending:
- 10,000 letters per day
- 5 letters per second
Next, we need to indicate and confirm the address that will be indicated in the letters in the From field.
In the Verified Senders menu, look for the Verify a new sender button.
So, just a little remains. We must create an IAM user, give him the right to send mail and assign him a key pair. We go here: https://console.aws.amazon.com/iam .
We create a new group:
Call it:
In the security policy templates we find the ready-made Amazon SES Full Access template :
After that, Next, Next, Next and created a user group.
The next step is to create a user in the Users menu:
Create a user and immediately generate a key pair for him:
User created:
Save a couple of his keys:
- Access Key Id: AKIAJXEPJQETZTN7HRNQ
- Secret Access Key: / T + wQ8xSOsm8BtkWcp6kdSSaDHRJT2imn / OoE660
Add the user to the group that was created before, thereby giving the user rights:
So, we have a couple of keys that are given the right to send letters to SES.
SPF record for the domain
In order to validate Amazon SES as a mail list, add an SPF record to your domain:
v = spf1 include: amazonses.com? All
Php mailer
Next, copy files to ourselves from the github.com/korjik/PHP-SES-mailer
ses.php repository - a class for connecting to SES - www.orderingdisorder.com/aws/ses
users.csv - an example of a list of users in the format
“username”, “ username@email.com »
send_email.php - the mail distribution program itself.
In send_email.php, you need to replace the following parameters:
Key pair:
$ ses = new SimpleEmailService (' Access Key Id ', ' Secret Access Key ');
Validated From address:
$ m-> setFrom (' validated@email.com ');
Next, fill in 2 text fields - the variables $ text_email and $ html_email with names are responsible for themselves.
If the preparations are done, the script can be run with the path parameter to the users.csv file:
$ php send_email.php users.csv
Total
All users specified in users.csv will receive emails.
Advice
Do not use a valid From address from foreign domains. Lack of SPF records increases the chance of emails getting into spam.
Tuning
As you noticed, we can insert a username, read as $ username = $ user_fields [0] from the CSV file , into each letter . Thus, you yourself can change the CSV format, add custom fields, etc.
If you have questions, write, I will answer.
Threat. The article is written specifically for Mr. m31 .