Implemented by | yii\mail\BaseMailer, yii\swiftmailer\Mailer |
---|---|
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/mail/MailerInterface.php |
MailerInterface is the interface that should be implemented by mailer classes.
A mailer should mainly support creating and sending mail messages. It should also support composition of the message body through the view rendering mechanism. For example,
Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) ->setFrom('[email protected]') ->setTo($form->email) ->setSubject($form->subject) ->send();
See also yii\mail\MessageInterface.
Method | Description | Defined By |
---|---|---|
compose() | Creates a new message instance and optionally composes its body content via view rendering. | yii\mail\MailerInterface |
send() | Sends the given email message. | yii\mail\MailerInterface |
sendMultiple() | Sends multiple messages at once. | yii\mail\MailerInterface |
Creates a new message instance and optionally composes its body content via view rendering.
public abstract 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:
|
$params | array |
The parameters (name-value pairs) that will be extracted and made available in the view file. |
return | yii\mail\MessageInterface |
Message instance. |
Sends the given email message.
public abstract boolean send ( $message ) | ||
---|---|---|
$message | yii\mail\MessageInterface |
Email message instance to be sent |
return | boolean |
Whether the message has been sent successfully |
Sends multiple messages at once.
This method may be implemented by some mailers which support more efficient way of sending multiple messages in the same batch.
public abstract integer sendMultiple ( array $messages ) | ||
---|---|---|
$messages | array |
List of email messages, which should be sent. |
return | integer |
Number of messages that are successfully sent. |
© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-mail-mailerinterface.html