Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon SES - Send HTML mail through PHP sdk

I am trying to send an email using amazon ses PHP sdk.

I got the following code. Working Fine

$body = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";


require_once('ses.php');
$ses = new SimpleEmailService('KEY', 'KEY');
$m = new SimpleEmailServiceMessage();
$m->addTo('[email protected]');
$m->setFrom('Test Support <[email protected]>');
$m->setSubject('Hello, world!');
$m->setMessageFromString($body);
print_r($ses->sendEmail($m));

This code pretty working well and I am confused how to send a HTML formatted mail through this script.

A body like this

$body='<div ><b>Name</b></div>';

Any one please help me Thanks in advance

like image 400
ramesh Avatar asked Mar 23 '23 09:03

ramesh


1 Answers

Ok think I have found the system you are using and it doesnt look like the standard SES api.

Try

$m->setMessageFromString($plainTextBody,$HTMLBody); 

Where you have the plain text version and html version of your emails defined in $plainTextBody and $HTMLBody before that line.

like image 99
Anigel Avatar answered Apr 02 '23 02:04

Anigel