Simple Email Service

Amazon Simple Email Service provides a simple way to send e-mails without having to maintain your own mail server.  This PHP class is a REST-based interface to that service.

A bit of example code will be a good demonstration of how simple this class is to use. Please read through these examples, and then feel free leave a comment if you have any questions or suggestions.

Update: Daniel Zahariev has forked the project and implemented the missing SendRawEmail functionality as well as Sig V4 support. You can download it at his github project page.

First, you’ll need to create a SimpleEmailService class object:

$ses = new SimpleEmailService('Access Key Here', 'Secret Key Here');

If this is your first time using Simple Email Service, you will need to request verification of at least one e-mail address, so you can send messages:

  [RequestId] => 1b086469-291d-11e0-85af-df1284f62f28

Every request you make to SimpleEmailService will return a request id. This id may be useful if you need to contact AWS about any problems.  For brevity, I will omit the request id if it is the only value returned from a service call.

After you’ve requested verification, you’ll get an e-mail at that address with a link. Click the link to get your address approved.  Once you’ve done that, you can use it as the ‘From’ address in the e-mails you send through SES.  If you don’t have production access yet, you’ll also need to request verification for all addresses you want to send mail to.

If you want to see what addresses have been verified on your account, it’s easy:

  [RequestId] => 77128e89-291d-11e0-986f-43f07db0572a
  [Addresses] => Array
      [0] =>
      [1] =>

Removing an address from the verified address list is just as easy:


This call will return a request id if you need it.

The only thing left to do is send an e-mail, so let’s try it. First, you’ll need a SimpleEmailServiceMessage object.  Then, you’ll want to set various properties on the message.  For example:

$m = new SimpleEmailServiceMessage();
$m->setSubject('Hello, world!');
$m->setMessageFromString('This is the message body.');

  [MessageId] => 0000012dc5e4b4c0-b2c566ad-dcd0-4d23-bea5-f40da774033c-000000
  [RequestId] => 4953a96e-29d4-11e0-8907-21df9ed6ffe3

And that’s all there is to it!

There are a few more things you can do with this class. You can make two informational queries, try these out:


For brevity I will not show the output of those two API calls. This information will help you keep track of the health of your account. See the Simple Email Service documentation on GetSendQuota and GetSendStatistics for more information on these calls.

You can set multiple to/cc/bcc addresses, either individually or all at once:

$m->addTo(array('', ''));
$m->addCC(array('', ''));
$m->addBCC(array('', ''));

These calls are cumulative, so in the above example, three addresses end up in each of the To, CC, and BCC fields.

You can also set one or more Reply-To addresses:

$m->addReplyTo(array('', ''));

You can set a return path address:


You can use the contents of a file as the message text instead of a string:

// or from a URL, if allow_url_fopen is enabled:

If you have both a text version and an HTML version of your message, you can set both:

$m->setMessageFromString($text, $html);

Or from a pair of files instead:

$m->setMessageFromFile($textfilepath, $htmlfilepath);
// or from a URL, if allow_url_fopen is enabled:
$m->setMessageFromURL($texturl, $htmlurl);

Remember that setMessageFromString, setMessageFromFile, and setMessageFromURL are mutually exclusive. If you call more than one, then whichever call you make last will be the message used.

Finally, if you need to specify the character set used in the subject or message:


The default is UTF-8 if you do not specify a charset, which is usually the right setting. You can read more information in the SES API documentation.

My version of this library does not support the SendRawEmail call, which means you cannot send emails with attachments or custom headers; however, Daniel Zahariev has forked the project and implemented this functionality. You can download it at his github project page.

Disclaimer: Although I work for Amazon, this class was neither produced, endorsed nor supported by Amazon.  I wrote this class as a personal project, just for fun.  While I no longer maintain it, I am happy to help resolve issues encountered while trying to use it.

319 thoughts on “Simple Email Service

  1. Ross

    Many, many thanks for this – a dream to use.

    I’ve spent 2 days trying to get working but when I do sendmail -bv there seems to be an issue with not retuning my host name that I cannot get around.

    This on the other hand worked first time – you’ve saved my sanity!

    1. moorthy


      I am troubling to change sender name instead of default user. can u help me how to use

  2. chylvina

    Hi Dan, thanks for your great work. I am using in my website.

    I have one question. How can I use html markup in setMessageFromString.

    I tried:
    setMessageFromString(‘hello world! hello world!’);

    But the line break does not work.


  3. chylvina

    Sorry, the html markup can not be displayed.

    setMessageFromString(‘hello world! &lt#BR#&gt hello world!’);

    1. Ericnyc

      Hey C, that works fine for me, but needs to be the 2nd arg to the function:

      $ses->setMessageFromString(‘text version or leave blank’,’html version <BR> hello world’);

    2. kev

      i found the solution.
      $m->setMessageFromString(‘ ‘,’html stuff here’);
      leave a space in the first part. if there is no space, it wont work.

  4. chylvina

    Hi, another issue here. It can reproduce some times.

    Notice: Undefined property: SimpleEmailServiceRequest::$resource in SimpleEmailServiceRequest->getResponse() (line 495 of /var/www/sites/all/libraries/ses.php).
    User warning: SimpleEmailService::sendEmail(): 7 couldn’t connect to host in SimpleEmailService->__triggerError() (line 361 of /var/www/sites/all/libraries/ses.php).

    1. Lionel

      Hi Chylvina,

      I just saw your post regarding Amazon AWS SES about the errors you get (Undefined property: SimpleEmailServiceRequest::$resource, etc).

      All of a sudden, I get exactly the same! Did you find out how to solve this?

      Thanks for any hint!

      Greetings from Switzerland,

  5. Damir Sečki

    Warning: SimpleEmailService::verifyEmailAddress(): 60 SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in D:\root\app\lib\3rd_party\amazon_ses.php on line 357

  6. blout

    Hi Dan,

    is it possible to send email to unverified addresses?
    well, from a verified address of course (which is ours).
    Because we don’t want our users to be confused between our service and aws caused by another verification process. Really need your help. Thx

  7. Alex Whittaker

    Thanks for code Dan, we have been using it for a few weeks and it runs nicely. My only thought is that it is pretty slow when cycling through a large list of email addresses – I get about 0.8 seconds per email which is a bit slow if you are hoping to reach an audience of millions! Have you given any thought to batching up the requests?



    1. Alex Whittaker

      Answering my own question, I guess BCC is probably the answer.

      1. Mauricio

        You could make asynchronous requests to the page that sends a specific email. So in a CRON job you would fire like 10 asynchronous requests to a page that sends email.

        At least you don’t need to use BCC.

        Also, by using asynchronous requests, your script will finish in no time.

      2. Douglas

        Hello, I have some speed issues also. The function sendEmail() takes a lot of time.

        I cannot use BCC, because each email is different (the name of the recipient is in the email).

        Do you have any idea how can I speed up the sendEmail() function?

  8. Rakesh Bhatt

    Hi, Thank’s a lot for this post i will be soon using this in my web site but i have a problem that can i set the from name and reply name as well in mail header along withe the email id’s. I didn’t get any way to do that. Thank’s in advance

    1. Dan

      Suppose you have a message object $m:

      $m->addTo('Joe Consumer <>');
      $m->setFrom('Customer Service <>');

      1. ron

        When i tried this
        $m->setFrom(‘Customer Service ‘);

        the mail is not able to send, there is no error though it’s just that the recipient will not receive the email

        but $m->setFrom(‘’) works fine

        Any idea what’s the problem?

        1. ron

          Strangely, the email is being taken out after post, notice below…

          $m->setFrom(‘Customer Service ‘);

  9. Andrew

    I have made some modifications to handle sending S/MIME messages. If you are interested in having this merged in, email me.

  10. Tomas

    Hi, if you want to make FROM name with diacritics, you have to use this way of setFrom:

    $m->setFrom(‘=?UTF-8?B?’.base64_encode(‘Sender name diacritics ěščřžýáí’).’?= ‘);

    1. Tomas

      sorry, i did not put it into code tag, so it was cut. Home it will be complete now … there was missing email address like Dan defined on August 20, 2012 at 7:50 pm:

      $m->setFrom('=?UTF-8?B?'.base64_encode('Sender name diacritics ěščřžýáí').'?= ');

  11. krishnaveni

    Notice: Undefined property: SimpleEmailServiceRequest::$resource in C:\wamp\www\TestApp\ses.php on line 491

    Warning: SimpleEmailService::verifyEmailAddress(): 60 SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in C:\wamp\www\TestApp\ses.php on line 357
    I am geeting this error plese help me on this

  12. Deepak

    Hi Dan,

    Could you please tell us how to add Dear {username} , dynamically in email body content.

    Please tell us how to write code for that.


  13. JoeB

    I cant get this to work, i’ve tried the very first example:

    $ses = new SimpleEmailService(
    'XXXXXXXX', // Access Key
    'XXXXXXXX' // Secret Key

    and i get this error:

    Notice: Undefined property: SimpleEmailServiceRequest::$resource in W:\Sites\lib\amazon-web-services\ses.class.php on line 492

    Warning: SimpleEmailService::listVerifiedEmailAddresses(): 60 SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in W:\Sites\lib\amazon-web-services\ses.class.php on line 358

    Any ideas?

    I’m running on my local machine for testing.

    1. JoeB

      Call this directly after creating the SimpleEmailService object:

      $ses = new SimpleEmailService('xxx', 'yyy');


      // do something...

      This disables checking of the certificate.
      Also recommended to set the SSL version to 3, on line 456:

      curl_setopt($curl, CURLOPT_SSLVERSION, 3); // add this line
      curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, ($this->ses->verifyHost() ? 1 : 0));
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, ($this->ses->verifyPeer() ? 1 : 0));

      See here:

  14. deepti

    Getting following error:
    RequestExpired [Message] => Request timestamp: Mon, 05 Nov 2012 15:47:06 UTC expired. It must be within 300 secs/ of server time. ) [RequestId] => 0e7127b8-2780-11e2-9236-496b230ed80a ) [code] => 400

        1. Dan

          If it’s a Linux server you can change the time using the “date” command, but you should probably set up ntp to automatically get the time set based on an authoritative server on the internet. Try googling some of that, it’s well beyond the scope of what I can help you with here 🙂

          1. deepti

            Hi Dan,

            Thanks for the reply the time issue is resolved, in linux server there is provision to change the server time.

            But if I try to send HTML email it send the HTML instead of sending formatted email

            Any Idea.


            1. Paul

              I too am experiencing HTML code in the emails. I am calling get_file_contents then replacing certain strings within it, ‘{RECIPIENT_NAME}’ for example, with data to personalize the email. But when I call setMessageFromString, I receive an email with HTML code displaying.

  15. hari

    I am getting this error, pls help me..

    Severity: User Warning

    Message: SimpleEmailService::verifyEmailAddress(): Sender – InvalidClientTokenId: The security token included in the request is invalid Request Id: 703cb75d-2e43-11e2-b610-5db26ab2c27e

    Filename: mails/ses.php

    Line Number: 362

      1. hari

        Ya this problem was solved yesterday only..that’s true credentials are wrong.
        Can we send bulk emails at once ? upto 50 or morethan 50?
        In sending bulk emails can we hide other mail id’s in ‘To’. Only who are the getting the mail that person mail id have to see by that person only.. it is possible .. help me..

  16. Steven


    Is it possible to set ‘from name’..
    like “Steven ”
    $m->setFrom(‘Steven ‘);

    instead of



  17. Omar A

    I’m not getting an error message (from SES) and no emails are sent. I have verified the domain and the email addresses I’m sending form on SES.

    Any Idea where can I find the error messages (nothing in the logs) or what could be the problem.

    1. Dan

      If you dump the response to the API call, one of the elements of the array will be a request id. You can give that to the SES team, either on the forums or via Developer Support, and they can figure out what happened to the request.

      If you’re not getting a request id, and the response array doesn’t contain an error message either, then the request probably isn’t making it to the service.

      (Note that even error responses should include a request id.)

    1. Dan

      Unfortunately the version of the library available on SourceForge does not support attachments.

      1. Andre

        Dan – does that imply there is another version somewhere that does? 😉

        I would be very interested in it.

        Many thanks,

  18. Pingback: Amazon Simple Email Service 初步使用 | INHd

  19. Pingback: 10 Great Resources for Web Developers

  20. Mahendra

    I am using your class for sending emails through amazon SES. I wanted to know how I could implement unsubscribe from list.
    Is there any generic function to implement this..?? any suggestions will highly be appreciated.
    Thanks in advance.

  21. thoman

    this is my error

    Warning: SimpleEmailService::sendEmail(): Sender - AccessDenied: User: arn:aws:iam::187953140120:user/smpt1 is not authorized to perform: ses:SendEmail Request Id: 91e99735-6ebf-11e2-a326-fd935e19d85f in /home/fake/public_html/fake/amazon_ses_phpmailer/ses.php on line 363

    1. Dan

      You’re using an IAM user that does not have permission to call the SendEmail API. You’ll need to add that permission to that IAM user (or talk to the person who gave you the credentials so they can do it).

  22. andrew

    Why do you trigger user warnings instead to provide the error/response in the response itself ? I think that’s a stupid thing and perhaps you are stupid too .

  23. Yuan

    I would like to pose a question about email header.

    If I want to use some header fields like “List-Unsubscribe”, “X-Complaints-To” and etc, what should I do? Could you give me some advice? Need I make some changes in “ses.php”?

    Thanks a lot!!


    1. Yuan

      Sorry I am not careful when i read the article at the first time.
      I just found this sentence:

      This library does not support the SendRawEmail call, which means you cannot send emails with attachments or custom headers, and unfortunately I will be unable to add that support.

      So, I still want your advice about using header fields while programming in PHP.

      Thanks in advance.

  24. Jon

    Wonderful bit of code, made my life much simpler! One question – is there a way to supply a “friendly” name as well as just an email address in the from field? In other words, an email client might display it as from “Customer Services” rather than “”.

    1. Dan

      If I remember correctly, you can specify a string like this:

      “Customer Services <>”

      as the From address. (You can do the same for To/CC/BCC addresses as well.)

      1. Jon

        Yes, you’re absolutely right. Whatever Amazon are paying you, it’s not enough!

  25. Karol


    Sorry for my English,

    I have a problem with the script … When I run it sends the email, but it shows this error:

    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in …

    Thanks for your help.



    1. Dan

      You can ignore that error message. Or you could fix the settings it’s complaining about 🙂

  26. Mohamed Alaa

    Hi Dan,

    Thank you for your amazing SES Class. It’s really very helpful.

    I just would like to know how to handle the errors in your class.

    let’s say i’m getting this error:

    Severity: User Warning

    Message: SimpleEmailService::sendEmail(): Sender - MessageRejected: Email address is not verified. Request Id: 4ae2b3bd-8676-11e2-ae73-3758a049155c

    Filename: app/ses.php
    Line Number: 363

    how could I catch it in my application?


    1. Dan

      If you look at the response object to the sendEmail() call, you should see some metadata in it. Try this:

      print_r($ses->sendEmail(… params here …));

      You can have your code examine the response to see if it’s an error.

  27. Marc-Antoine


    I am sure that your class is stable but it hasn’t been updated since 2011. I suppose the API was updated since then, so currently is there any issue or important missing functionality? Moreover, is there any specific reason to use the official SDK instead of your class (besides the attachment and raw sending capabilities)?

    Thanks a lot!

    1. Dan

      The SES API has been updated since this class was released, but I don’t know the full list of newer features off the top of my head.

      One reason to use the official AWS SDK is that AWS supports the official SDK, and frequently releases bugfixes, improvements, and newer features. The SDK also supports a wide variety of services, not just SES.

      The feedback I’ve been given both here on this site and by e-mail is that some people find the official SDK to be less usable and/or too bulky compared to my SES class.

  28. Navin

    After reading all post .I if am understanding right then there is not provision of attachments. Correct me if am wrong?

    1. Will

      Nope. No Attachments. This Is A “Get You Going” Script… BUT SES Will Allow Attachments. If Anyone Needs A Sample, Hit Me Up.

  29. Arshad

    i find this article very helpful but can anyone give me script for attachment too, thanks in advance

  30. Feyisayo

    Thanks a lot for this. I have used it a number of times and it works.

    Thanks again.

  31. Dave

    When I use do this:
    $htmlurl = ‘’;

    The email received is the raw html (I.e. all the tags are seen etc.) – How do I fix that?

    Email message body:
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
    <title>Untitled Document</title>
    <meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>


    Hello world!!!!


  32. hese

    Thanks for this awesome PHP class!

    For some reason, I cant get multiple “addBcc” addresses to work:

    $m->addBCC(array(‘’, ‘’));

    This will only send email to the first address.

    Any ideas whats wrong?

  33. HuangFei

    $ses = new SimpleEmailService(‘[access key]’, ‘[secret key]’);

    above is my code,the flowing is display:

    Notice: Undefined property: SimpleEmailServiceRequest::$resource in F:\PHPnow-1.5.6\htdocs\amazonwms\SES\ses.php on line 491
    Warning: SimpleEmailService::verifyEmailAd

    please tell me why ???

    1. Dan Post author

      You shouldn’t put your access key and secret key in forum or blog posts 🙂 I removed them, but I still strongly recommend you delete the keypair you are currently using and generate a new one.

      I think there’s a bug in the SES class somewhere. If the verifyEmailAddress call still works, don’t worry about it. Or, you could fix the warning!

  34. budy

    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, ‘<' not found in C:\xampp\htdocs\email\ses.php on line 499

    Warning: simplexml_load_string() [function.simplexml-load-string]: 220 ESMTP SimpleEmailService-376766033 in C:\xampp\htdocs\email\ses.php on line 499

    Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\xampp\htdocs\email\ses.php on line 499

    Warning: SimpleEmailService::verifyEmailAddress(): Encountered an error: Array in C:\xampp\htdocs\email\ses.php on line 366

  35. Kesava

    Hi there,
    I have peculiar problem,

    except sendEmail, all other functions are working properly.


    All the above functions returning values properly.

    My debug skills shows, sendEmail function is returning false from
    if($rest->error !== false)

    $this->__triggerError(‘sendEmail’, $rest->error);
    print (“I am here “);
    return false;

    Can someone throw light on this problem?

    Please note, I got production access to my SES.

    Thanks in advance

  36. Rajesh Bute

    Does anyone know that how to implement the amazon SNS service in php, basically i need notification whenever bounce happens so i can ignore next time.

    Thanks in advance!

  37. Nikhil

    Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead in E:\ambitionME\local_server\Public\ses.php on line 456

    Notice: Undefined property: SimpleEmailServiceRequest::$resource in E:\ambitionME\local_server\Public\ses.php on line 491

    Warning: SimpleEmailService::getSendQuota(): 60 SSL certificate problem: unable to get local issuer certificate in E:\ambitionME\local_server\Public\ses.php on line 357

    i got these errors while executing following code:
    $con=new SimpleEmailService(“AKIAIL6PZPAZ7KZG7WHA”,”AtIr6VRyOoZu033vEHsSW4x3HPUMpFyeArIUCiVXaQOM”);

  38. abhishek

    Hey frnd,
    we have using this service.
    How can we send attachments with email ?
    thanks in advanced,

  39. L.Mohan Arun


    If I use

    the Sender Name shows up as ‘user’ when
    I receive the email in gmail.

    How can I set a “From Name:”?
    I checked ses.php and couldnt find something
    that will let me set up a ‘from’ sender name…

    Any guidance appreciated.


  40. Nrao

    verifyEmailAddress(‘[valid email addr]’));
    Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value 2 will be used instead in E:\xampp\htdocs\email\ses.php on line 456
    Notice: Undefined property: SimpleEmailServiceRequest::$resource in E:\xampp\htdocs\email\ses.php on line 491
    Warning: SimpleEmailService::verifyEmailAddress(): 60 SSL certificate problem: unable to get local issuer certificate in E:\xampp\htdocs\email\ses.php on line 357

    plz help me out in gettin the access to send mail……
    thanks in advance

    1. Willet

      Hi! I’m getting the exact same error. Did you ever discover the problem? Thanks!

    2. mt

      Search for CURLOPT_SSL_VERIFYHOST in the ses code and update 1 : 0 to 2 : 0.

      Per php.met under CURLOPT_SSSL_VERIFYHOST: Support for value 1 removed in cURL 7.28.1.

  41. Ishan

    Hiii dear,

    I have a problem occurring in the above code, i want your help.
    Please reply me if you have solution of my problem.

    And the problem is that “SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. ”

    And also tell me that why i am getting this type of problem…

  42. Divine


    The function/class works perfectly until recently. We got internal server error when trying to send an email message with great body content length,example:

    Hi there,

    Sorry you were unable to make your scheduled free trial appointment today. Please have a look at your schedule and let us know when you’d like to rebook.

    Only 1 week left of our January Special!

    Please keep in mind when booking your next appointment that we appreciate notice when unable to make the day/time you select. We often bring in extra Trainers to accomodate multiple free trial appointments.

    Don’t miss out on the workout everyone is talking about & getting results from!

    See you soon!

    These are what we found in the error log.

    PHP Warning: SimpleEmailService::verifyEmailAddress(): 56 SSL read: error:00000000:lib(0):func(0):reason(0), errno 104 in /home/hit/public_html/includes/ses/ses.php on line 357

    PHP Warning: SimpleEmailService::sendEmail(): Sender – InvalidParameterValue: Illegal content.
    Request Id: a3db4db4-85ff-11e3-ae5e-a39300faa3b8
    in /home/hit/public_html/includes/ses/ses.php on line 363

    Any thoughts? please help us out. thank you.

  43. David

    I have to create unique body text for each email (specific activation code etc.)

    How do I clear/replace the “To”, “Subject”, and “Body” data in the SimpleEmailServiceMessage() object?

  44. Joydeep

    Where is the ses.php file? Do I need to download and save it in the web directory? Where do I download it from? The github page doesn’t have any ses.php.

  45. Tsanko

    I’m sending email form verified email and verified domain but when “addTo(” is not verified domain or mail I’m getting

    Warning: SimpleEmailService::sendEmail(): Sender – MessageRejected: Email address is not verified. Request Id: e9ea3b28-33b0-11e4-81db-19c405f16db2 in /home/bgmailor/public_html/ses/SimpleEmailService.php on line 377

    My SES is not in sandbox

  46. Rodrigo Valentim

    Pls, Where is the ses.php ????
    ses.php = SimpleEmailService.php?

    i get this error on execute class by command line

    $m->setSubject(‘Hello, world!’);
    $m->setMessageFromString(‘This is the message body.’);



    [root@ip]# php test.php

    PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, ‘<' not found in /usr/share/php/php-aws-ses-master/src/SimpleEmailServiceRequest.php on line 142
    PHP Warning: simplexml_load_string(): 220 ESMTP SimpleEmailService-805484607 RwhQZGEsNkaNdeBn in /usr/share/php/php-aws-ses-master/src/SimpleEmailServiceRequest.php on line 142
    PHP Warning: simplexml_load_string(): ^ in /usr/share/php/php-aws-ses-master/src/SimpleEmailServiceRequest.php on line 142
    PHP Warning: SimpleEmailService::sendEmail(): Encountered an error: Array in /usr/share/php/php-aws-ses-master/src/SimpleEmailService.php on line 380

  47. Matt

    Looks like this script is not caching “Email Address Not Verified” and fails with:

    Fatal error: Class ‘TL_Error’ not found in ses.php on line 364

    Any Idea why?

  48. Mike

    I’ve used this tool for over a year with great success, then today (10/17/14) I get this error message:

    Warning: SimpleEmailService::sendEmail(): 35 Unknown SSL protocol error in connection to in ses.php on line 357

    The mail is not sent.

    Nothing has changed on my side. Here’s a simplified version of the code that produces the error: (it’s a direct copy from above)

    $ses = new SimpleEmailService(‘Access Key Here’, ‘Secret Key Here’);
    $m = new SimpleEmailServiceMessage();
    $m->setSubject(‘Hello, world!’);
    $m->setMessageFromString(‘This is the message body.’);


    Any thoughts what would cause this or how to fix?


    1. Ted

      Hi! I had the same problem.

      I added this line to line 449:

      curl_setopt($curl, CURLOPT_SSLVERSION, 4);

      Note, “4” instead of “3”. Now it works again!

  49. John Paul

    Can anyone of you please tell how to set region in above code while sending mail

    1. blavv

      This should’ve been documented, but you can specify the region as the third argument to the constructor like this:

      $ses = new SimpleEmailService(‘Access Key Here’, ‘Secret Key Here’, $region);

      for instance, if you’re on US West 2, then

      $region = ’’;

      This argument is optional and set to US East 1 by default btw.

      should do.

  50. Jeff A

    I’m having an issue where users doing this from Windows NT machines are getting multiple emails from Amazon. This doesn’t happen when they are on Macs, other Windows versions, or iPads. Any reason why this would be happening?

  51. SM

    Just took a quick glance at this and seems to be what I want as I only need SES ability. I am confused though how we know if an email successfully sent if we want to do some logic on our side for success/failed.

    In the comments above you state:
    If you dump the response to the API call, one of the elements of the array will be a request id. You can give that to the SES team, either on the forums or via Developer Support, and they can figure out what happened to the request.

    If you’re not getting a request id, and the response array doesn’t contain an error message either, then the request probably isn’t making it to the service.

    (Note that even error responses should include a request id.)

    So, according to this the response array always contains a request id regardless… if it contains a message id that means it succeeded? You also state the response array will contain the error message if there is one, but glancing at the code it wouldn’t appear so.

  52. Mike

    Have been using this solution for 2 years. Absolutely wonderful. Until I upgraded to PHP 5.6. Now with every send, I get this error message:

    An error occurred in script ‘<>/ses.php’ on line
    Undefined property: stdClass::$body
    Date/Time: 9-9-2015 21:25:44
    [curl] => Resource id #11
    [data] =>




    It runs just fine on PHP 5.4, but after upgrading to 5.6, I get this error. Can anyone help?


    1. Mike

      Providing a solution to my question…
      I moved to Daniel Zahariev’s code and the problem went away. The only change I made was to
      change this line:
      to this:

  53. supplement

    How are you handling authorization… oauth? any ideas about oauth?

    I saw this portion of code..

    $auth = ‘AWS3-HTTPS AWSAccessKeyId=’.$this->ses->getAccessKey();
    $auth .= ‘,Algorithm=HmacSHA256,Signature=’.$this->__getSignature($date);
    $headers[] = ‘X-Amzn-Authorization: ‘ . $auth;

  54. Twiddly

    Any update for Amazon’s new SES signature v4?

    Got a notice saying
    Amazon Simple Email Service is ending support for Signature Version 3 effective September 30, 2020

  55. ghi

    PHP Warning: SimpleEmailService::verifyEmailAddress(): 23 Failed writing body (0 != 430) in awsmail/ses.php on line 357

    1. zooli

      plz help me
      PHP Warning: SimpleEmailService::verifyEmailAddress(): 23 Failed writing body (0 != 430) in awsmail/ses.php on line 357

  56. sefa

    PHP Fatal error: Call to undefined method SimpleEmailServiceMessage::setMessageTag() in rsrg/abc.php on line 72


Leave a Reply

Your email address will not be published. Required fields are marked *