Sfoglia il codice sorgente

Fixes #4071: `mail` component renamed to `mailer`, `yii\log\EmailTarget::$mail` renamed to `yii\log\EmailTarget::$mailer`

Alexander Makarov 11 anni fa
parent
commit
91f05a2891

+ 1 - 1
config/web.php

@@ -17,7 +17,7 @@ $config = [
         'errorHandler' => [
         'errorHandler' => [
             'errorAction' => 'site/error',
             'errorAction' => 'site/error',
         ],
         ],
-        'mail' => [
+        'mailer' => [
             'class' => 'yii\swiftmailer\Mailer',
             'class' => 'yii\swiftmailer\Mailer',
             // send all mails to a file by default. You have to set
             // send all mails to a file by default. You have to set
             // 'useFileTransport' to false and configure a transport
             // 'useFileTransport' to false and configure a transport

+ 1 - 1
models/ContactForm.php

@@ -49,7 +49,7 @@ class ContactForm extends Model
     public function contact($email)
     public function contact($email)
     {
     {
         if ($this->validate()) {
         if ($this->validate()) {
-            Yii::$app->mail->compose()
+            Yii::$app->mailer->compose()
                 ->setTo($email)
                 ->setTo($email)
                 ->setFrom([$this->email => $this->name])
                 ->setFrom([$this->email => $this->name])
                 ->setSubject($this->subject)
                 ->setSubject($this->subject)

+ 2 - 2
tests/unit/models/ContactFormTest.php

@@ -13,7 +13,7 @@ class ContactFormTest extends TestCase
     protected function setUp()
     protected function setUp()
     {
     {
         parent::setUp();
         parent::setUp();
-        Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
+        Yii::$app->mailer->fileTransportCallback = function ($mailer, $message) {
             return 'testing_message.eml';
             return 'testing_message.eml';
         };
         };
     }
     }
@@ -54,7 +54,7 @@ class ContactFormTest extends TestCase
 
 
     private function getMessageFile()
     private function getMessageFile()
     {
     {
-        return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
+        return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml';
     }
     }
 
 
 }
 }

+ 2 - 2
views/site/contact.php

@@ -22,9 +22,9 @@ $this->params['breadcrumbs'][] = $this->title;
     <p>
     <p>
         Note that if you turn on the Yii debugger, you should be able
         Note that if you turn on the Yii debugger, you should be able
         to view the mail message on the mail panel of the debugger.
         to view the mail message on the mail panel of the debugger.
-        <?php if (Yii::$app->mail->useFileTransport): ?>
+        <?php if (Yii::$app->mailer->useFileTransport): ?>
         Because the application is in development mode, the email is not sent but saved as
         Because the application is in development mode, the email is not sent but saved as
-        a file under <code><?= Yii::getAlias(Yii::$app->mail->fileTransportPath) ?></code>.
+        a file under <code><?= Yii::getAlias(Yii::$app->mailer->fileTransportPath) ?></code>.
         Please configure the <code>useFileTransport</code> property of the <code>mail</code>
         Please configure the <code>useFileTransport</code> property of the <code>mail</code>
         application component to be false to enable email sending.
         application component to be false to enable email sending.
         <?php endif; ?>
         <?php endif; ?>