Amazon SES SMTP in PHPMailer: Send Email Using AWS SES and PHPMailer in CI
With having a large number of features, amazon become a popular hosting service provider. In this tutorial we will see how to send Email using AWS SES and PHPMailer with SMTP Configuration. We will see step by step this implementation.
Get SMTP Credentials from AWS SES:
To get SMTP Credentials from Amazon SES you need to do following simple things:
- Login to your amazon console account.To login click here Sign in to AWS Account.
- Go to the Simple Email Service Section(You can search it from search bar by typing Simple Email Service).
- Select SMTP Settings from left sidebar menu.
- Click on “Create My SMTP Credential” button to generate SMTP credentials.
- Copy username and password to use in your application.
Setting up AWS SES SMTP Credentials in PHPMailer:
To use SMTP in PHPMailer .
To set from(Sender) Email Address.
Replace firstname.lastname@example.org with your “From” address. This address must be verified with Amazon SES. You can verify domain name on AWS SES. After verifying you will be able to send email from any email ID which is ended with this domain.To add recipient address in PHPMailer.
$mail->addAddress('email@example.com', 'Recepient Name');
Replace firstname.lastname@example.org with a “To” address. You can include several address to send email to multiple recipients.To set AWS SES SMTP user name in PHPMailer.
$mail->Username = 'Your AWS SMTP User Name';
Replace SMTP password with your Amazon SES SMTP password.To setup configuration
If you do not want to use a configuration set, comment or remove above line.To set Host Name.
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
If you’re using Amazon SES in a region other than US West (Oregon), replace email-smtp.us-east-1.amazonaws.com with the Amazon SES SMTP endpoint in the appropriate region.