Amazon Simple Email Service PHP example

finally Amazon release an affordable bulk mail service. Amazon Simple Email Service (Amazon SES) (beta). this is very useful.

As far as pricing goes, Amazon will charge fees for the number of e-mails sent and data transfers. Pricing for SES is US$ 0.10 per thousand messages sent. A customer may also send 2,000 e-mail messages per day free of charge when these e-mails originate from Amazon EC2

here is the open source php class

http://sourceforge.net/projects/php-aws-ses/


Updates
===========

sample code

step 1
include and make a new instance of class

include_once('ses.php');
$con=new SimpleEmailService("your access key","your secretKey ");

step 2
if you are using ses first time you need to add a verified email adders to send mail from. following code will help you to add and verify email address

include_once('ses.php');
$con=new SimpleEmailService("your access key","your secretKey ");
$con->verifyEmailAddress('anilmathewm@mail.com');

once you run the code you will get a mail from amazon ses service to verify the email address by clicking a link.once you verify the code you can use the email address as sender email

step 3

if you want to check the verified email address then use the following code.

include_once('ses.php');
$con=new SimpleEmailService("your access key","your secretKey ");
$con->listVerifiedEmailAddresses();

step 4

how to send an email with Amazon Simple Email Service


include_once('ses.php');
$con=new SimpleEmailService("your access key","your secretKey ");
$con->listVerifiedEmailAddresses();

$m = new SimpleEmailServiceMessage();
$m->addTo('anilmathewm@mail.com');
$m->setFrom('anilmathewm@mail.com');
$m->setSubject('Hello, world!');
$m->setMessageFromString('This is the message body.');
$con->sendEmail($m);


NOTE:

most impotent


If you have not yet requested production access to Amazon SES, then you will only be able to send email to and from verified email addresses. For more information, go to the Developer Guide.

14 comments:

Satish Panchal said...
This comment has been removed by the author.
Mike said...

I've verified my amazon ses account and got my account moved to the production server, but I'm getting the following error:


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 D:\Hosting\4505330\html\myadmin\ses.php on line 357

Warning: SimpleEmailService::sendEmail(): 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:\Hosting\4505330\html\myadmin\ses.php on line 357

You know what this is all about?

Lonelypx said...

the issue is related with the curl Please check the curl settings

Anonymous said...

To answer boogster's question - you just need to set the following:

$ses->enableVerifyPeer(false);

TurK said...

Thx for the class. It saved lots of my time.

phamhphuc said...
This comment has been removed by a blog administrator.
Jirka said...

Thanks Brad, it helped me a lot!

Macrosoft said...

Excellent email services in php.

PHP Development Company

Unknown said...

Hi,

I'm getting the bellow error message:

Warning: SimpleEmailService::listVerifiedEmailAddresses(): Sender - 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. Request Id: 3072e2e6-3fb6-11e3-a412-13a2672745c6 in /public_html/includes/core/core.SimpleEmailService.php on line 363

Do you know what might be the problem?

Steve Sensenig said...

You are a lifesaver! I could not run their SDK on my server because my PHP version is not high enough and I'm not quite ready for the testing and troubleshooting that will come with upgrading from 5.2 (Their SDK requires at least 5.3). I kept trying to find some PHP examples for calling the API directly, and kept finding SDK examples. When I stumbled on your class and tried it, what a relief it was to have it work right out of the gate! Thank you SO much!! You saved me hours or days of pain. :)

Unknown said...

Thank you for the information. You have a very good article. I found it informative and useful. Keep up the good work.

Best Regards,
CourseIng - AWS Training in Hyderabad

Unknown said...

It is really a great work and the way in which you are sharing the knowledge is excellent and thank you for sharing. Click Here: Python Online Training || Python Online Course

Neelima said...

Nice post, good information, this information is very useful, you explained a lot about this topic. We provide this AWS training with real-time exports and 100% placement program. For more details visit our website AWS Training

Sowmiya R said...

Awesome,Thank you so much for sharing such an awesome blog
Thanks for one marvelous posting! I enjoyed reading it; you are a great author.
oracle training in chennai

oracle training institute in chennai

oracle training in bangalore

oracle training in hyderabad

oracle training

hadoop training in chennai

hadoop training in bangalore


PHP developer Cochin |PHP developer Kerala | PHP developer India | Flash developer/programmer Cochin | Flash developer/programmer Kerala | Flash developer/programmer India | web programmer kerala |web programmer Cochin |web programmer India |web developer kerala |Web developer Cochin | Kerala PHP | PHP freelancer| flash actionscript freelancer