Search code examples
amazon-web-servicesemailamazon-ses

How to change the email that SES sends from?


Right now I have a few domains verified in AWS. I just started using SES with SMTP to send some emails from contact forms/password resets on my site but have run into a bit of an issue.

I have the domain example.com verified and am wanting to send emails from no-reply@example.com but whenever I send them it sends from my work email me@example.com

What can I do to get this setup? I posted on Reddit and was told that I can setup CloudFormation in order to do it but that seems way over complicated for what I'm trying to do. I just want to change the email that it's sent from on a verified domain, I would assume that's pretty simple.

Any help would be great, thanks!


Solution

  • I used SES with the SMTP interface (from a .net application), and because my domains are verified, all I need to do is change the 'FROM' address, and it will send from whichever email address I want.

    Here is a code example:

                using (var msg = new MailMessage())
                {
                    msg.From = new MailAddress("anything@my-verified-domain.com");
                    msg.To.Add(s.EmailAddress);
                    msg.Subject = "Test Subject";
                    msg.Body = body;
                    msg.IsBodyHtml = true;
                    msg.Headers.Add("X-SES-CONFIGURATION-SET", "configset-1");
                    using (var smtp = new SmtpClient())
                    {
                        smtp.Send(msg);
                    }
                }
    

    Maybe if you shared some code we could see where you are going wrong.