Interface yii\mail\MailerInterface
| 实现 | yii\mail\BaseMailer |
|---|---|
| 可用版本自 | 2.0 |
| 源码 | https://github.com/yiichina/yii2/blob/api/framework/mail/MailerInterface.php |
MailerInterface 是应该由邮件程序类实现的接口。
邮件程序应主要支持创建和发送 mail messages。 它还应该通过视图渲染机制支持消息体的组合。例如,
Yii::$app->mailer->compose('contact/html', ['contactForm' => $form])
->setFrom('from@domain.com')
->setTo($form->email)
->setSubject($form->subject)
->send();
公共方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| compose() | 创建新的消息实例,并可选择通过视图渲染来组合其正文内容。 | yii\mail\MailerInterface |
| send() | 发送给定的邮件。 | yii\mail\MailerInterface |
| sendMultiple() | 一次发送多条消息 | yii\mail\MailerInterface |
方法详情
创建新的消息实例,并可选择通过视图渲染来组合其正文内容。
| public abstract yii\mail\MessageInterface compose($view = null, array $params = []) | ||
| $view | string|array|null | 用于渲染邮件内容的视图。可以是:
|
| $params | array | 将提取并且在视图文件中用的参数(键值对)。 |
| return | yii\mail\MessageInterface | 消息实例。 |
|---|---|---|
发送给定的邮件。
| public abstract boolean send($message) | ||
| $message | yii\mail\MessageInterface | 要发送的电子邮件实例 |
| return | boolean | 消息是否已成功发送 |
|---|---|---|
一次发送多条消息
此方法可以支持更高效的在同一批中发送多个消息。
| public abstract integer sendMultiple(array $messages) | ||
| $messages | array | 应发送的电子邮件列表。 |
| return | integer | 成功发送的消息数。 |
|---|---|---|