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

Anil Mathew said...

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

Brad said...

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

$ses->enableVerifyPeer(false);

Ferhat 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!

subbu raj said...

Excellent email services in php.

PHP Development Company

InnomaxMediaLLP said...

I really enjoy to read all the content is posted on your blog. It's easy to read, the content is great, and you’re an educated writer unlike most of the blogs.thanks for the post.
Web development Company

Roman Sargu 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. :)

Fully Help said...

Nice blog...Very useful information is providing by ur blog. Great beginning php tutorials Very clear and helpful for beginners.

Srinadh said...

A smallish campaign with a homemade list would not be likely to yield much of a result. To achieve anything worthwhile, a much more aggressive effort is needed. Then, the age-old value analysis applies: projected earnings = margin on total projected sales - cost of campaign.

Srinadh said...

A smallish campaign with a homemade list would not be likely to yield much of a result. To achieve anything worthwhile, a much more aggressive effort is needed. Then, the age-old value analysis applies: projected earnings = margin on total projected sales - cost of campaign.


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