29

I'm starting with the amazon servers and started studying about SES. I am using asp.net C # and made ​​my code based tutorials. I already checked the domain and also checked the emails in which I will run the test.

So that when I run my code it generates the following error message: Transaction failed. The server response was: Message rejected: Email address is not verified.

I do not know what it is because I followed all possible steps, single detail is not yet ordered the release of access to production.

But I think it can not be, I'm still testing the service.

My Code

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);
            }

        }
leedream
  • 502
  • 1
  • 4
  • 19

4 Answers4

58

Your code indicates that you are trying to send via us-west-2. Have you requested production access in that region, and is your From address verified? Production access for Amazon SES is region-independent and you need to request it separately for each region.

If you do not have production access, you should make sure that both From and To addresses are verified. The Amazon SES console will list your verified email addresses and verified domains for us-west-2. The Amazon SES blog has additional guidance on how you can get set up in us-west-2.

A quick way to tell if you do not have production access: log in to the Amazon SES console dashboard and it will display a blue banner with the following text at the top of the page with a button to request production access:

Your Amazon SES account has "sandbox" access in region US West (Oregon). With sandbox access you can only send email to the Amazon SES mailbox simulator and to email addresses or domains that you have verified. Learn more.

Can't find your existing account settings? Your account may be set up in a different AWS region. Try switching regions in the upper right corner of the console.

Rohan Deshpande
  • 3,137
  • 1
  • 20
  • 29
  • this is just so subtle. almost took it for a random suggestion and missed it. they should have a tab menu for "request production access". Anyway thanks. – roopunk Mar 11 '15 at 19:43
  • 5
    i am lost, not in sandbox mode, verified domain, verified from address, and still the "not vrrified email" error. any more tips?? – tom Sep 02 '15 at 21:55
  • Exact same issue here @tom Did you figure it out? – Sharry Mar 10 '16 at 16:43
  • ...i did... ..now to remember ))). ...it was a switch up, something with my email provider.... or maybe it was those pesky regions, like EU Ireland versus Oregon USA.... Or maybe I mixed up the domain of my gmail email address with my personal domain... ...it was definitely a mix up of two things on my part.... ...i definitely had to setup a POP3 server so that my verified from address matched my verified domain. – tom Mar 10 '16 at 20:06
  • @Rohan Deshpande Are you sure about "f you do not have production access, you should make sure that both From and To addresses are verified."? How do I send emails to my registered users? My backend does not validates their emails. – Ricardo Mar 17 '20 at 23:28
5

Are you by chance still running in 'sandbox' mode? If you are, you can only send emails to addresses that have been pre-verified.

From Amazon:

Email address is not verified—Your account is in the sandbox and one of the recipient email addresses has not been verified. This might apply to "Sender", "Return-Path", or "From" addresses.

If you have not requested production access to Amazon SES, you must verify every recipient email address except for the recipients provided by the Amazon SES mailbox simulator. You must also verify your own "From" address. For more information, see Verifying Email Addresses and Domains in Amazon SES and Testing Amazon SES Email Sending.

More information here: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/ses-errors.html

E.J. Brennan
  • 42,120
  • 6
  • 74
  • 108
  • 1
    I feel kind of confused as to check, if the finding of the control panel (http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html) I already did. – leedream Mar 02 '14 at 14:42
  • 1
    I am trying to integrate aws ses into an office management software. Where the users can send email to their clients. I have a doubt here. Even though I have moved of sandbox mode. And my domain is also verified. Whenever the user tries to send the mail to their clients, it gives an error `email address not verified`. Is this because the user and clients email addresses are not verified. Or is there any other reason. – beingyogi Feb 17 '20 at 09:49
  • @YogeshKudikala - recipients do not need their email addresses verified once you are no longer running in sandbox mode, so there is something else going on; it would be completely impractical to require all recipients to be verified before you could send email to them. – E.J. Brennan Feb 17 '20 at 13:00
3

After weeks of messing around, I finally sorted this out. So if you are out of the sandbox, have verified your domain and your FROM email address, beware of the default Region. As you already know (just a guess), being out of the sandbox is region-specific (as well as the verified email and domain).

My problem was that I was that in all of the permutations of how to send an email with AWS SDK Java, I was not able to specify an explicit region and my USA account was defaulting the region to USA West. My Region where I did all of the verification (and was out of the Sandbox) was Europe West (email-smtp.eu-west-1.amazonaws.com). Also don't forget to use the proper credentials for Amazon SES API which are the AWS access keys. In my case (below) those keys are in a file, in the classpath with two key-value pairs:

accessKey = AKI...
secretKey = AsVyp...

And here is the code:

import java.io.IOException;

import java.util.ArrayList;
import java.util.Properties;
import java.util.Arrays;


import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.simpleemail.AWSJavaMailTransport;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.amazonaws.services.simpleemail.model.ListVerifiedEmailAddressesResult;
import com.amazonaws.services.simpleemail.model.VerifyEmailAddressRequest;
//import com.amazonaws.services.ec2.model.Region;
import com.amazonaws.services.simpleemail.*;
import com.amazonaws.services.simpleemail.model.*;
import com.amazonaws.regions.*;

public class AmazonSESSample {

static final String FROM = "john@myappsdomain.com";  
static final String TO = "me@mypersonalaccount.com";                                                       // 
static final String BODY = "This email was sent through Amazon SES by using the AWS SDK for Java.";
static final String SUBJECT = "Amazon SES test (AWS SDK for Java)";


public static void main(String[] args) throws IOException {     

    // Construct an object to contain the recipient address.
    Destination destination = new Destination().withToAddresses(new String[]{TO});

    // Create the subject and body of the message.
    Content subject = new Content().withData(SUBJECT);
    Content textBody = new Content().withData(BODY); 
    Body body = new Body().withText(textBody);

    PropertiesCredentials credentials = new PropertiesCredentials(
            AmazonSESSample.class
                    .getResourceAsStream("AwsCredentials.properties"));

    Message message = new Message().withSubject(subject).withBody(body);
    SendEmailRequest request = new SendEmailRequest().withSource(FROM).withDestination(destination).withMessage(message);

    try
    {        

        AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(credentials);
        Region REGION = Region.getRegion(Regions.EU_WEST_1);
        client.setRegion(REGION);
        client.sendEmail(request);  
        System.out.println("Email sent!");
    }
    catch (Exception ex) 
    {
        System.out.println("The email was not sent.");
        System.out.println("Error message: " + ex.getMessage());
    }
}

}

tom
  • 2,020
  • 1
  • 18
  • 27
3

Also double check to make sure your not running in production mode and/or make sure your sending TO address is verified in Sandbox Mode.

Limitations of AWS SES Sandbox Mode:

  • You can only send mail to the Amazon SES mailbox simulator and to verified email addresses and domains.
  • You can only send mail from verified email addresses and domains.
  • You can send a maximum of 200 messages per 24-hour period.
  • Amazon SES can accept a maximum of one message from your account per second.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html

Bas van Stein
  • 9,955
  • 3
  • 22
  • 60