Question

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('mail@gmail.com');
$m->setFrom('Test Support <test@test.com>');
$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

Was it helpful?

Solution

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.

OTHER TIPS

If you are following the example here then do this to send html emails with css

$request['Message']['Body']['Html']['Data'] = $to;

That is replace the Text key with Html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top