2016-03-23 9 views
1

は私の設定です:Yii2ではSwiftMailerは、デフォルトのメール経由で電子メールを送信しない()関数

'mailer' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'viewPath' => '@common/mail', 
      'transport' => [ 
       'class' => 'Swift_MailTransport', 
      ], 
      'useFileTransport' => False, 
     ], 

私も以下で試してみました:

'mailer' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'viewPath' => '@common/mail', 
      'useFileTransport' => False, 
     ], 

私は電子メールを送信するには、次のコードを使用しています:

var_dump(\Yii::$app->mailer->compose() 
        ->setTo($email) 
        ->setFrom(\Yii::$app->params['supportEmail']) 
        ->setSubject('Message subject') 
        ->setTextBody('Plain text content') 
        ->setHtmlBody('<b>HTML content</b>') 
        ->send()); 

例外がスローされるたびにfalseを返します。

私はmail()関数を使用して同じ内容の電子メールを送信しましたが、その罰金と電子メールは即座に送信されます。しかし、問題はSwiftMailerだけです。

デバッグ方法が見つかりませんでした。私はYii2Debuggerを有効にしていますが、私はその情報も罰金できません。

編集:

私はGmailのSMTPを試みたが、私は

Connection could not be established with host smtp.gmail.com [Connection timed out #110] 

を得ている私は、私はそれにすべてのエラーを取得し、まだのための偽の届かない、そのデフォルトSMTPを試してみましたそれ。

私たちは共有しています。 PHPの設定を確認する必要があります。

あなたのメーラーにご web.php Configで

答えて

0

この1

'mailer' => [ 
     'class' => 'yii\swiftmailer\Mailer', 
     'useFileTransport' => false, 
     'transport' => [ 
      'class' => 'Swift_SmtpTransport', 
      'host' => 'smtp.gmail.com', 
      'username' => 'Your Gmail Account ex:[email protected]', 
      'password' => 'Password', 
      'port' => '587', 
      'encryption' => 'ssl',         
     ], 
], 
+0

私はデフォルトのメール(とそれを構成する)この設定を試してみてくださいsmtpではなく関数です。 –

-1

'mailer' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'useFileTransport'=>false, 
      // send all mails to a file by default. You have to set 
      // 'useFileTransport' to false and configure a transport 
      // for the mailer to send real emails. 

      'transport' => [ 
       'class' => 'Swift_SmtpTransport', 
       'host' => 'smtp.gmail.com', 
       'username' => '[email protected]', 
       'password' => 'yourpassword', 
       'port' => '465', 
       'encryption' => 'ssl', 
      ], 
     ], 

はそれが役に立てば幸い:)

+0

私はそれをsmtpではなく、デフォルトのmail()関数で設定します。 –

関連する問題