JJS
JJS

Reputation: 326

Use html file as body of Zend mail\message

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.

Upvotes: 1

Views: 1346

Answers (1)

WayneC
WayneC

Reputation: 5740

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);

Upvotes: 1

Related Questions