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. You can download it at his github project page.

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

require_once('ses.php');
$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:

print_r($ses->verifyEmailAddress('user@example.com'));
-------
Array
(
  [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:

print_r($ses->listVerifiedEmailAddresses());
-------
Array
(
  [RequestId] => 77128e89-291d-11e0-986f-43f07db0572a
  [Addresses] => Array
    (
      [0] => user@example.com
      [1] => recipient@example.com
    )
)

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

$ses->deleteVerifiedEmailAddress('user@example.com');

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->addTo('recipient@example.com');
$m->setFrom('user@example.com');
$m->setSubject('Hello, world!');
$m->setMessageFromString('This is the message body.');

print_r($ses->sendEmail($m));
-------
Array
(
  [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:

print_r($ses->getSendQuota());
print_r($ses->getSendStatistics());

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('jim@example.com');
$m->addTo(array('dwight@example.com', 'angela@example.com'));
$m->addCC('holly@example.com');
$m->addCC(array('kelly@example.com', 'ryan@example.com'));
$m->addBCC('michael@example.com');
$m->addBCC(array('kevin@example.com', 'oscar@example.com'));

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('andy@example.com');
$m->addReplyTo(array('stanley@example.com', 'erin@example.com'));

You can set a return path address:

$m->setReturnPath('noreply@example.com');

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

$m->setMessageFromFile('/path/to/some/file.txt');
// or from a URL, if allow_url_fopen is enabled:
$m->setMessageFromURL('http://example.com/somefile.txt');

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:

$m->setSubjectCharset('ISO-8859-1');
$m->setMessageCharset('ISO-8859-1');

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 (the RDS team, specifically), 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.

307 Comments »

 
  • Ross says:

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

    I’ve spent 2 days trying to get ses-send-email.pl 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!
    Thanks!

  • chylvina says:

    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.

    Thanks!

  • chylvina says:

    Sorry, the html markup can not be displayed.

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

    • Ericnyc says:

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

    • kev says:

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

  • chylvina says:

    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).

    • Lionel says:

      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,
      Lionel

  • Damir Sečki says:

    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

  • blout says:

    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

  • Alex Whittaker says:

    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?

    Cheers,

    ..alex

    • Alex Whittaker says:

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

      • Mauricio says:

        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.

  • Rakesh Bhatt says:

    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

    • Dan says:

      Suppose you have a message object $m:

      $m->addTo('Joe Consumer <joe@example.com>');
      $m->setFrom('Customer Service <service@example.com>');

      • ron says:

        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(‘service@example.com’) works fine

        Any idea what’s the problem?

  • Andrew says:

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

  • shankar says:

    i am looking php script for ses can any one help me asap

  • Frank says:

    Great class, very helpful. Thanks

  • Tomas says:

    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 ěščřžýáí’).’?= ‘);

    • Tomas says:

      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 ěščřžýáí').'?= ');

  • Aaron says:

    I needed something like this as a drop-in replacement for the PHP internal mail() function, and my Google-fu found nothing so I wrote one.

    https://github.com/aaaaron/ses_mail/

  • krishnaveni says:

    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

  • Deepak says:

    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.

    Thanks.

  • JoeB says:

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

    $ses = new SimpleEmailService(
    'XXXXXXXX', // Access Key
    'XXXXXXXX' // Secret Key
    );
    print_r($ses->listVerifiedEmailAddresses());
    exit();

    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.

  • deepti says:

    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

    • Dan says:

      This error usually happens when your machine’s clock is wrong.

      • deepti says:

        I am having a dedicated server, How can I change the time of the server.
        any Ides.

        • Dan says:

          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 :)

          • deepti says:

            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.

            Thanks

            • Paul says:

              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.

  • hari says:

    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

    • Dan says:

      Make sure you’re using the correct AWS Access Key and Secret Key.

      • hari says:

        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..

  • Steven says:

    Hey,

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

    instead of

    $m->setFrom(‘my@email.com’);

    thanks

  • Oleg says:

    Thanks, works perfectly!

  • Omar A says:

    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.

    • Dan says:

      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.)

  • Srinivas says:

    Hi,

    Great article. It works perfectly.
    How can i send attachments ?

    Thanks
    Sri

  • […] day for pennies. If you want a nice PHP class that makes it super easy, I have add success with the php class by Ordering Disorder. If are anti-Amazon or something you can check out PostMark app. I ran through a trial with them […]

  • Mahendra says:

    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.

  • thoman says:

    Hello
    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

    • Dan says:

      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).

  • andrew says:

    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 .

  • Yuan says:

    Hi,
    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!!

    Yuan

    • Yuan says:

      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.
      Yuan

  • Jon says:

    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 “custservices@company.com”.

  • Karol says:

    Hi,

    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.

    regards,

    Karol

  • Mohamed Alaa says:

    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?

    Thanks,
    Mohamed

    • Dan says:

      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.

  • Marc-Antoine says:

    Hello,

    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!

    • Dan says:

      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.

  • Navin says:

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

  • Will says:

    In A Word…. SWEET!

    Thanks Man!

  • Arshad says:

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

  • Feyisayo says:

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

    Thanks again.
    Feyisayo

  • Dave says:

    When I use do this:
    $htmlurl = ‘http://www.example.com/email.htm';
    $m->setMessageFromURL($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”>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
    </head>

    <body>

    Hello world!!!!

    </body>
    </html>

  • hese says:

    Thanks for this awesome PHP class!

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

    $m->addTo(‘myemail@gmail.com’);
    $m->addBCC(array(‘my2ndemail@domain.com’, ‘my3rdemail@domain.com’));

    This will only send email to the first myemail@gmail.com address.

    Any ideas whats wrong?

  • HuangFei says:

    require_once(‘ses.php’);
    $ses = new SimpleEmailService(‘[access key]’, ‘[secret key]’);
    print_r($ses->verifyEmailAddress(‘aiernet@126.com’));

    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 ???

    • Dan says:

      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!

  • Alvin says:

    Thanks for this awesome PHP class :D

  • budy says:

    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 email-smtp.amazonaws.com 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

  • Kesava says:

    Hi there,
    I have peculiar problem,

    except sendEmail, all other functions are working properly.

    print_r($ses->listVerifiedEmailAddresses());
    print_r($ses->getSendQuota());
    print_r($ses->getSendStatistics());

    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
    Regards
    Kesava

  • Kesava says:

    Got it by printing the $rest–>error!
    Policy issues at AWS level.

    –Kesava

  • Rajesh Bute says:

    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!

  • Nikhil says:

    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:
    include_once(‘ses.php’);
    $con=new SimpleEmailService(“AKIAIL6PZPAZ7KZG7WHA”,”AtIr6VRyOoZu033vEHsSW4x3HPUMpFyeArIUCiVXaQOM”);
    print_r($con->getSendQuota());die();

  • Nikhil says:

    how can i convert an email with attachments into a raw email??

  • abhishek says:

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

  • L.Mohan Arun says:

    Hi,

    If I use
    $m->setFrom(‘user@mydomain.com’);

    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.

    Thanks,

  • Nrao says:

    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

    • Willet says:

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

    • mt says:

      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.

  • Ishan says:

    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…

  • Divine says:

    Hi,

    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.

  • David says:

    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?

  • Joydeep says:

    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.

  • Mark Baker says:

    @Joydeep – the github repo for ses is linked at the top of the page: https://github.com/daniel-zahariev/php-aws-ses

  • Tsanko says:

    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

  • Rodrigo Valentim says:

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

    i get this error on execute class by command line

    addTo(‘XXX@XXXXX’);
    $m->setFrom(‘XXXX@XXXXX’);
    $m->setSubject(‘Hello, world!’);
    $m->setMessageFromString(‘This is the message body.’);

    print_r($ses->sendEmail($m));

    ?>

    [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 email-smtp.amazonaws.com 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

  • Matt says:

    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?

  • Mike says:

    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 email.us-east-1.amazonaws.com:443 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)

    require_once(‘ses.php’);
    $ses = new SimpleEmailService(‘Access Key Here’, ‘Secret Key Here’);
    $ses->enableVerifyPeer(false);
    $m = new SimpleEmailServiceMessage();
    $m->addTo(‘toaddress@here.com’);
    $m->setFrom(‘fromaddress@here.com’);
    $m->setSubject(‘Hello, world!’);
    $m->setMessageFromString(‘This is the message body.’);

    print_r($ses->sendEmail($m));

    Any thoughts what would cause this or how to fix?

    thanks,

    • Ted says:

      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!

  • Excellent goods from you, man. I have take into
    account your stuff previous to and you’re simply extremely wonderful.
    I really like what you have obtained right here, certainly
    like what you’re stating and the way during which you say it.
    You make it entertaining and you still care for to stay it wise.
    I can not wait to learn much more from you. This is really a terrific
    website.

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>