mail\BaseMailer compose()

compose() public method

Creates a new message instance and optionally composes its body content via view rendering.

public yii\mail\MessageInterface compose ( $view = null, array $params = [] )
$view string|array|null

The view to be used for rendering the message body. This can be:

  • a string, which represents the view name or path alias for rendering the HTML body of the email. In this case, the text body will be generated by applying strip_tags() to the HTML body.
  • an array with 'html' and/or 'text' elements. The 'html' element refers to the view name or path alias for rendering the HTML body, while 'text' element is for rendering the text body. For example, ['html' => 'contact-html', 'text' => 'contact-text'].
  • null, meaning the message instance will be returned without body content.

The view to be rendered can be specified in one of the following formats:

  • path alias (e.g. "@app/mail/contact");
  • a relative view name (e.g. "contact") located under $viewPath.
$params array

The parameters (name-value pairs) that will be extracted and made available in the view file.

return yii\mail\MessageInterface

Message instance.

doc_Yii
2016-10-30 17:07:04
Comments
Leave a Comment

Please login to continue.