Setup SMTP Configuration using AWS SES

Published
AWS Simple Email Service (SES) is a cloud-based SASS platform that allows you to send emails to your customers. Amazon SES sends email using SMTP, which is the most common email protocol on the internet. It allows sending large volumes of email in minutes.
To setup SMTP configuration using AWS SES, follow the steps below:
  • Navigate to Amazon SES console.
  • From the navigation pane, choose SMTP Settings.
  • Under Under Simple Mail Transfer Protocol (SMTP) settings, note the values for SMTP endpoints and Ports. Use the SMTP endpoint and ports to connect to SMTP. For example, if you're in the ap-southeast-1 AWS Region, note the following:
    SMTP endpoint: email-smtp.ap-southeast-1.amazonaws.com
    Port: 25, 465 or 587AWS SES SMTP Configuration
  • Click on Create SMTP Credentials, which will redirect you to IAM Console. For Create User for SMTP, type a name for your SMTP user in the User Name field and click on Create user in the bottom-right corner.AWS SES SMTP User
  • Note the SMTP Username and SMTP Password for your SMTP user. Alternatively, you can download the CSV file.AWS SES SMTP Credentials
Now that you have the SMTP credentials, you need to verify the email address with SES before you can send emails. Email addresses can be verified individually or through domain verification. For more details about verification, please check how to Verify Email and Domain Identities in AWS SES.
To check the configuration, you can create a simple Node.js app that sends an email using the SMTP credentials.
aws / ses.js
const nodemailer = require("nodemailer"); async function sendEmail(to, subject, body) { // Configure SMTP transporter const transporter = nodemailer.createTransport({ host: "email-smtp.<region>.amazonaws.com", // Replace with your AWS SES region port: 587, // Use 465 for SSL, 587 for TLS secure: false, // false for TLS, true for SSL auth: { user: "YOUR_SMTP_USERNAME", // Replace with your SMTP username pass: "YOUR_SMTP_PASSWORD" // Replace with your SMTP password } }); // Email options const mailOptions = { from: "your-email@example.com", // Must be a verified SES sender email to: to, subject: subject, text: body, // Plain Text body html: `<p>${body}</p>` // HTML body }; try { const info = await transporter.sendMail(mailOptions); console.log("Email sent successfully:", info.messageId); } catch (error) { console.error("Error sending email:", error); } } // Example Usage sendEmail("recipient@example.com", "Test Email", "This is a test email from AWS SES using SMTP in Node.js.");
Replace YOUR_SMTP_USERNAME and YOUR_SMTP_PASSWORD with the SMTP credentials you noted earlier. The from email address must be a verified SES sender email. You can also customize the email body with plain text and HTML.
Hopefully, this guide helps you set up SMTP configuration using AWS SES, allowing you to successfully send emails via SMTP. If you have any questions or feedback, feel free to leave a comment below.
Write your Comment