Use html file as body of Zend mail\message

1.2k views Asked by At

Not sure what's the syntax of having html files rendered when added to Zend\Mail\Message?

Here's a piece of code I have:

$mail = new Mail\Message();
$html = file_get_contents('content.html');
$mail->setBody($html);

Is it sufficient to set it up like this or do I need to specify the type of content somehow?

Thanks.

1

There are 1 answers

2
WayneC On

You can attach it as a Mime part.

Example from the docs:

use Zend\Mail\Message;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part as MimePart;


$html = new MimePart($htmlMarkup);
$html->type = "text/html";

$body = new MimeMessage();
$body->setParts(array($text, $html, $image));

$message = new Message();
$message->setBody($body);