1

I have used the following code for sending mail using php using amazon ec2, but I only see 'aatest' as the result, and doesn't get any incoming email. Btw, I have already included ses.php, and have validated the email contact@mydomain.com, and double confirm that accesskey, and accesskey are the correct one. Can anyone suggest way for debugging it?

require_once('ses.php');
$con=new SimpleEmailService('accesskey','accesskey');
print_r('aa'.$con->listVerifiedEmailAddresses());


$m = new SimpleEmailServiceMessage();
$m->addTo('contact@mydomain.com');
$m->setFrom('contact@mydomain.com');
$m->setSubject('Hello, world!');
$m->setMessageFromString('This is the message body.');
print_r($con->sendEmail($m));
echo 'test';
william007
  • 117
  • 5
  • Have you tried putting `error_reporting(E_ALL);` at the top of your code? Have you tried disabling the SSL certificate check by doing `$con->enableVerifyHost(false); $con->enableVerifyPeer(false);`? – SameOldNick Sep 17 '12 at 03:33
  • Yes, it works by adding $con->enableVerifyHost(false); $con->enableVerifyPeer(false); ! What is the reason for that? Btw, could you post it as an answer, so I could accept it :) – william007 Sep 17 '12 at 05:10

1 Answers1

2

Disable the SSL certificate check with the following lines:

$con->enableVerifyHost(false);
$con->enableVerifyPeer(false);

The reason its failing the SSL certificate verification is because the certificate for SES is not recognized by the default CA (Certificate Authority) loaded with cURL. I believe you have to generate your own certificate for AWS by going to https://portal.aws.amazon.com/gp/aws/securityCredentials and clicking on "X.509 Certificates" and "Create a new certificate". You will then be able to download the certificate. However, unless your knowledgeable about PHP you won't be able to include the certificate file with that PHP class. So your best just to disable the verification.

SameOldNick
  • 566
  • 6
  • 23