Html
Html
MIME part representing an HTML email body.
class Html extends \Hazaar\Mail\Mime\Part implements \JsonSerializableHandles multipart/alternative encoding, template rendering, and conversion to string or JSON. Supports setting template parameters and encoding both HTML and plain text versions for email clients.
Properties
boundary
Boundary string for multipart/alternative encoding.
private string $boundaryhtml
The HTML template instance for rendering the email body.
private Template $htmlparams
Parameters to be passed to the HTML template for rendering.
private array $paramsMethods
__construct
Constructs a new Html MIME part for email messages.
public __construct(Template $html, array $headers): voidAccepts either a string or a Template instance for the HTML content. Sets up the multipart/alternative boundary and content type.
Parameters
| Parameter | Type | Description |
|---|---|---|
$html | Template | the HTML content or Template instance to use for rendering the email body |
$headers | array | optional headers to include in the MIME part |
__toString
Converts the HTML MIME part to a string by encoding it.
public __toString(): stringsetParams
Sets the parameters for the HTML template rendering.
public setParams(array $params): voidThese parameters are used when rendering the HTML content for the email body.
Parameters
| Parameter | Type | Description |
|---|---|---|
$params | array | associative array of template parameters to set |
encode
Encodes the HTML MIME part as a multipart/alternative message.
public encode(int $widthLimit = 998): stringRenders the HTML template with the set parameters, creates both HTML and plain text parts, and combines them using the boundary for email clients.
Parameters
| Parameter | Type | Description |
|---|---|---|
$widthLimit | int | the maximum line width for encoding (default: 998) |
jsonSerialize
Serializes the HTML MIME part for JSON encoding.
public jsonSerialize(): mixedReturns an array containing the type, headers, and rendered HTML content for use in JSON representations.
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:23 +0000