I am trying to send an email from email1 to email2. But I am getting the following error:
Transaction failed. The server response was: Message rejected: Email address is not verified. The following identities failed the check in region CA-CENTRAL-1: [email protected], Sender Name [email protected], [email protected]
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
Email("DO TEST");
}
public static void Email(string htmlString)
{
String FROM = "[email protected]";
String FROMNAME = "Sender Name";
String TO = "[email protected]";
String SMTP_USERNAME = "kiffretM5C2PFESI5W";
String SMTP_PASSWORD = "BLeMDSkjioourdvhvbhvhTMHAVfuG6mcAXibbTmQpe7WX";
String HOST = "email-smtp.ca-central-1.amazonaws.com";
int PORT = 587;
String SUBJECT =
"Amazon SES test (SMTP interface accessed using C#)";
// The body of the email
String BODY =
"<h1>Amazon SES Test</h1>" +
"<p>This email was sent through the " +
"<a href='https://aws.amazon.com/ses'>Amazon SES</a> SMTP interface " +
"using the .NET System.Net.Mail library.</p>";
MailMessage message = new MailMessage();
message.IsBodyHtml = true;
message.From = new MailAddress(FROM, FROMNAME);
message.To.Add(new MailAddress(TO));
message.Subject = SUBJECT;
message.Body = BODY;
using (var client = new System.Net.Mail.SmtpClient(HOST, PORT))
{
client.Credentials =
new NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);
client.EnableSsl = true;
try
{
Console.WriteLine("Attempting to send email...");
client.Send(message);
Console.WriteLine("Email sent!");
}
catch (Exception ex)
{
Console.WriteLine("The email was not sent.");
Console.WriteLine("Error message: " + ex.Message);
}
}
}
}
}
2
Answers
It would appear that you are using Amazon SES in sandbox mode.
From Moving out of the Amazon SES sandbox – Amazon Simple Email Service:
While operating in sandbox mode, you will need to verify every email address before it can receive email.
I had the same problem. I solved it by setting up the VM in google console and display the corresponding code, copied it to a command line, changed –maintenance-policy=MIGRATE to –maintenance-policy=TERMINATE, and created the VM from the command line.