Property | Type | Description | |
---|---|---|---|
$fileTransportCallback | a PHP callback that will be called by BaseMailer::send when [[useFileTransport]] is true. The callback should return a file name which will be used to save the email message. If not set, the file name will be generated based on the current timestamp. The signature of the callback is: php function ($mailer, $message) | ||
$fileTransportPath | the directory where the email messages are saved when [[useFileTransport]] is true. | ||
$htmlLayout | HTML layout view name. This is the layout used to render HTML mail body. The property can take the following values: - a relative view name: a view file relative to [[viewPath]], e.g., 'layouts/html'. - a path alias: an absolute view file path specified as a path alias, e.g., '@app/mail/html'. - a boolean false: the layout is disabled. | ||
$messageClass | the default class name of the new message instances created by BaseMailer::createMessage | ||
$messageConfig | the configuration that should be applied to any newly created email message instance by BaseMailer::createMessage or BaseMailer::compose. Any valid property defined by MessageInterface can be configured, such as from, to, subject, textBody, htmlBody, etc. For example: php [ 'charset' => 'UTF-8', 'from' => '[email protected]', 'bcc' => '[email protected]', ] | ||
$textLayout | text layout view name. This is the layout used to render TEXT mail body. Please refer to [[htmlLayout]] for possible values that this property can take. | ||
$useFileTransport | whether to save email messages as files under [[fileTransportPath]] instead of sending them to the actual recipients. This is usually used during development for debugging purpose. |
Method | Description | |
---|---|---|
afterSend ( yii\mail\MessageInterface $message, boolean $isSuccessful ) | This method is invoked right after mail was send. | |
beforeSend ( yii\mail\MessageInterface $message ) : boolean | This method is invoked right before mail send. | |
compose ( string | array | null $view = null, array $params = [] ) : yii\mail\MessageInterface | Creates a new message instance and optionally composes its body content via view rendering. | |
generateMessageFileName ( ) : string | ||
getView ( ) : |
||
getViewPath ( ) : string | ||
render ( string $view, array $params = [], string | boolean $layout = false ) : string | Renders the specified view with optional parameters and layout. | |
send ( yii\mail\MessageInterface $message ) : boolean | Sends the given email message. | |
sendMultiple ( array $messages ) : integer | Sends multiple messages at once. | |
setView ( array | |
||
setViewPath ( string $path ) |
Method | Description | |
---|---|---|
createMessage ( ) : yii\mail\MessageInterface | Creates a new message instance. | |
createView ( array $config ) : |
Creates view instance from given configuration. | |
saveMessage ( yii\mail\MessageInterface $message ) : boolean | Saves the message as a file under [[fileTransportPath]]. | |
sendMessage ( yii\mail\MessageInterface $message ) : boolean | Sends the specified message. |
public beforeSend ( yii\mail\MessageInterface $message ) : boolean | ||
$message | yii\mail\MessageInterface | |
return | boolean | whether to continue sending an email. |
public compose ( string | array | null $view = null, array $params = [] ) : yii\mail\MessageInterface | ||
$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. |
protected createMessage ( ) : yii\mail\MessageInterface | ||
return | yii\mail\MessageInterface | message instance. |
protected createView ( array $config ) : |
||
$config | array | view configuration. |
return | view instance. |
public generateMessageFileName ( ) : string | ||
return | string | the file name for saving the message when [[useFileTransport]] is true. |
public getViewPath ( ) : string | ||
return | string | the directory that contains the view files for composing mail messages Defaults to '@app/mail'. |
public render ( string $view, array $params = [], string | boolean $layout = false ) : string | ||
$view | string | the view name or the path alias of the view file. |
$params | array | the parameters (name-value pairs) that will be extracted and made available in the view file. |
$layout | string | boolean | layout view name or path alias. If false, no layout will be applied. |
return | string | the rendering result. |
protected saveMessage ( yii\mail\MessageInterface $message ) : boolean | ||
$message | yii\mail\MessageInterface | |
return | boolean | whether the message is saved successfully |
abstract protected sendMessage ( yii\mail\MessageInterface $message ) : boolean | ||
$message | yii\mail\MessageInterface | the message to be sent |
return | boolean | whether the message is sent successfully |
public sendMultiple ( array $messages ) : integer | ||
$messages | array | list of email messages, which should be sent. |
return | integer | number of messages that are successfully sent. |
public setViewPath ( string $path ) | ||
$path | string | the directory that contains the view files for composing mail messages This can be specified as an absolute path or a path alias. |
public $fileTransportCallback |
public $fileTransportPath |
public $htmlLayout |
public $messageClass |
public $messageConfig |
public $textLayout |