I am working on a service that sends emails from AWS SES service. I have been able to send plain text mails but I require to send rich HTML mails in one of the case. This is the code that I use:
header("MIME-Version: 1.0; Content-type: text/html; charset=iso-8859-1");
require_once(dirname(__FILE__).'/AWSSDKforPHP/sdk.class.php');
// Instantiate the Amazon class
$ses = new AmazonSES();
$source = '[email protected]';
$dest = array('ToAddresses'=>array($to));
$message = CFComplexType::map(array('Subject.Data'=>$subject, 'Body.Html.Data'=>$message_mail));
$rSendEmail = $ses->send_email($source, $dest, $message);
message_mail is some HTML text put inside tables. I have tried both send_email and send_raw_email but both of them did not work. Do I need to do something extra or different?
I know it's old question but still writing an answer. And hoping it will help someone in future.
$m = new SimpleEmailServiceMessage();
$m->addTo('receiver email address');
$m->setFrom('send email address');
$m->setSubject('testing!');
$body= '<b>Hello world</b>';
$plainTextBody = '';
$m->setMessageFromString($plainTextBody,$body);
print_r($ses->sendEmail($m));
this worked for me (without using the sdk or smtp):
require_once('ses.php');
$ses = new SimpleEmailService('accessKey', 'secretKey');
$m = new SimpleEmailServiceMessage();
$m->addTo('[email protected]');
$m->setFrom('Name <[email protected]>');
$m->setSubject('You have got Email!');
$m->setMessageFromString('Your message');
$ses->sendEmail($m);
You can get ses.php from http://www.orderingdisorder.com/aws/ses/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With