Articles → AWS → Amazon Simple Email Service In AWS

Amazon Simple Email Service In AWS






Purpose





How To Create SES?




  1. Verify the email address
  2. Create SMTP credentials



Verify The Email Address




Picture showing the Amazon Simple Email Service in the search result of the AWS console




Picture showing the Get set up link




Picture showing the Verify a New Email Address button for verifying the sender email address




Picture showing the a screen to select the identity type




Picture showing  a section of screen to enter the email address




Picture showing  the Create identity button




Picture showing the verification email on the specified email address




Picture showing the status of the email as verified



Create SMTP Credentials




Picture showing the button for creating the SMTP credentials




Picture showing the screen to specify the IAM user name used as SMTP credentails




Picture showing the SMTP credentails created using the SES





Send An Email Using SES Credentials


using System;
using System.Net;
using System.Net.Mail;

namespace SESDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            // Replace with your AWS SES SMTP credentials
            string smtpUsername = "[User Name]";
            string smtpPassword = "[Password]";

            // SMTP endpoint for the AWS SES region (e.g., us-east-1)
            string host = "email-smtp.ap-south-1.amazonaws.com";
            int port = 587; // Port 587 for TLS, or 465 for SSL

            // Email details
            string from = "admin@gyansangrah.com";
            string to = "User@gmail.com";
            string subject = "Test Email from AWS SES";
            string body = "Hello, this is a test email sent using C# and AWS SES SMTP.";

            // Create a new SmtpClient object to send the email
            SmtpClient client = new SmtpClient(host, port);
            client.UseDefaultCredentials = false;

            client.EnableSsl = true;
            client.Credentials = new NetworkCredential(smtpUsername, smtpPassword);
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            

            try
            {
                // Create the MailMessage object
                MailMessage message = new MailMessage(from, to, subject, body);

                // Send the email
                client.Send(message);
                Console.WriteLine("Email sent successfully!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to send email. Error: " + ex.Message);
            }
        }
    }
}


Picture showing  mail sent using SES credentials



Posted By  -  Karan Gupta
 
Posted On  -  Monday, November 1, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250