我正在学习关于SES并开始使用亚马逊服务器。我使用asp.net C#编写代码,基于教程进行学习。我已经检查了域名,并检查了将要运行测试的电子邮件。
当我运行我的代码时,它生成了以下错误信息:事务失败。服务器响应为:消息被拒绝:电子邮件地址未经验证。
我不知道这是什么原因,因为我按照所有可能的步骤进行了操作,唯一的问题是我还没有获得访问生产环境的权限。
但我认为这不可能是问题所在,因为我仍在测试该服务。
我的代码:
public void enviarSES02()
{
try
{
const String FROM = "verified email address";
const String TO = "verified email address";
const String SUBJECT = "Amazon SES test (SMTP interface accessed using C#)";
const String BODY = "This email was sent through the Amazon SES SMTP interface by using C#.";
const String SMTP_USERNAME = "my username"; // Replace with your SMTP username.
const String SMTP_PASSWORD = "my password"; // Replace with your SMTP password.
const String HOST = "email-smtp.us-west-2.amazonaws.com";
const int PORT = 25;//already tried with all recommended ports
SmtpClient client = new SmtpClient(HOST, PORT);
client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);
client.EnableSsl = true;
try
{
Console.WriteLine("Attempting to send an email through the Amazon SES SMTP interface...");
client.Send(FROM, TO, SUBJECT, BODY);
Response.Write("ENVIADO");
}
catch (Exception ex)
{
Response.Write("<br>O e-mail não foi enviado.<br>");
Response.Write("Olhao erro: " + ex.Message);
}
}
catch (Exception ex)
{
Response.Write("Error message: " + ex.Message);
}
}