Search code examples
phpamazon-web-servicesamazon-ses

Amazon SES error while sending email MessageRejected


i am using php to send email with Amazon SES and using this github library

https://github.com/okamos/php-ses#getting-started

but when i send i get this error my email and domain both are verified

     "MessageRejected" ["description"]=> string(134) "Indicates that the action failed, and the message could not be sent. Check the error stack for a description of what caused the error." } 

when i checked for this error in aws i found this

 https://docs.aws.amazon.com/ses/latest/DeveloperGuide/troubleshoot-error-messages.html

here it says
If you call the Amazon SES API directly, the Query action will return an error. The error may be MessageRejected or one of the errors specified in the Common Errors topic of the Amazon Simple Email Service API Reference.

where we are missing ??

require 'autoload.php';

require 'src/ses.php';


$ses = new SimpleEmailService(
    'xxxxxxxxx',
    'xxxxxxxxxxxx', 
    'us-east-1' 
);


$envelope = new SimpleEmailServiceEnvelope(
    'noreply@xxxxxxxx.com',
    'This is test email',
    'Hello how are you. this is test email'
);


$envelope->addTo('ffffff@hhhhh.com');

$requestId = $ses->sendEmail($envelope);

var_dump($requestId);

why we are getting this error


Solution

  • The best practice when you are sending mails via SES, specially if you are sending a lot of them, is use queues. For example, you can use AWS SQS to send mails via SES and avoid that problem.