|
|
@ -14,25 +14,27 @@ use yii\mail\BaseMailer; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Mailer implements a mailer based on SwiftMailer. |
|
|
|
* Mailer implements a mailer based on SwiftMailer. |
|
|
|
* |
|
|
|
* |
|
|
|
* To use Mailer, you should configure it in the application configuration like the following, |
|
|
|
* To use Mailer, you should configure it in the application configuration like the following: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~ |
|
|
|
* ```php |
|
|
|
* 'components' => [ |
|
|
|
* [ |
|
|
|
* ... |
|
|
|
* 'components' => [ |
|
|
|
* 'mailer' => [ |
|
|
|
* 'mailer' => [ |
|
|
|
* 'class' => 'yii\swiftmailer\Mailer', |
|
|
|
* 'class' => 'yii\swiftmailer\Mailer', |
|
|
|
* 'transport' => [ |
|
|
|
* 'transport' => [ |
|
|
|
* 'class' => 'Swift_SmtpTransport', |
|
|
|
* 'class' => 'Swift_SmtpTransport', |
|
|
|
* 'host' => 'localhost', |
|
|
|
* 'host' => 'localhost', |
|
|
|
* 'username' => 'username', |
|
|
|
* 'username' => 'username', |
|
|
|
* 'password' => 'password', |
|
|
|
* 'password' => 'password', |
|
|
|
* 'port' => '587', |
|
|
|
* 'port' => '587', |
|
|
|
* 'encryption' => 'tls', |
|
|
|
* 'encryption' => 'tls', |
|
|
|
|
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
|
|
|
|
* // ... |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ... |
|
|
|
* // ... |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ~~~ |
|
|
|
* ``` |
|
|
|
* |
|
|
|
* |
|
|
|
* You may also skip the configuration of the [[transport]] property. In that case, the default |
|
|
|
* You may also skip the configuration of the [[transport]] property. In that case, the default |
|
|
|
* PHP `mail()` function will be used to send emails. |
|
|
|
* PHP `mail()` function will be used to send emails. |
|
|
@ -41,7 +43,7 @@ use yii\mail\BaseMailer; |
|
|
|
* You can also specify the list of plugins, which should be registered to the transport using |
|
|
|
* You can also specify the list of plugins, which should be registered to the transport using |
|
|
|
* 'plugins' key. For example: |
|
|
|
* 'plugins' key. For example: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~ |
|
|
|
* ```php |
|
|
|
* 'transport' => [ |
|
|
|
* 'transport' => [ |
|
|
|
* 'class' => 'Swift_SmtpTransport', |
|
|
|
* 'class' => 'Swift_SmtpTransport', |
|
|
|
* 'constructArgs' => ['localhost', 25] |
|
|
|
* 'constructArgs' => ['localhost', 25] |
|
|
@ -52,17 +54,17 @@ use yii\mail\BaseMailer; |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ], |
|
|
|
* ~~~ |
|
|
|
* ``` |
|
|
|
* |
|
|
|
* |
|
|
|
* To send an email, you may use the following code: |
|
|
|
* To send an email, you may use the following code: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~ |
|
|
|
* ```php |
|
|
|
* Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) |
|
|
|
* Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) |
|
|
|
* ->setFrom('from@domain.com') |
|
|
|
* ->setFrom('from@domain.com') |
|
|
|
* ->setTo($form->email) |
|
|
|
* ->setTo($form->email) |
|
|
|
* ->setSubject($form->subject) |
|
|
|
* ->setSubject($form->subject) |
|
|
|
* ->send(); |
|
|
|
* ->send(); |
|
|
|
* ~~~ |
|
|
|
* ``` |
|
|
|
* |
|
|
|
* |
|
|
|
* @see http://swiftmailer.org |
|
|
|
* @see http://swiftmailer.org |
|
|
|
* |
|
|
|
* |
|
|
@ -83,6 +85,7 @@ class Mailer extends BaseMailer |
|
|
|
* @var bool whether to enable writing of the SwiftMailer internal logs using Yii log mechanism. |
|
|
|
* @var bool whether to enable writing of the SwiftMailer internal logs using Yii log mechanism. |
|
|
|
* If enabled [[Logger]] plugin will be attached to the [[transport]] for this purpose. |
|
|
|
* If enabled [[Logger]] plugin will be attached to the [[transport]] for this purpose. |
|
|
|
* @see Logger |
|
|
|
* @see Logger |
|
|
|
|
|
|
|
* @since 2.0.4 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $enableSwiftMailerLogging = false; |
|
|
|
public $enableSwiftMailerLogging = false; |
|
|
|
|
|
|
|
|
|
|
|