2016-10-06 7 views
1

YII2 - メールは常にファイルとして保存されますが、useFileTransportにもかかわらず、送信されていない=私はYii2生産サイトからメールを送信しようとしていますが、メールは常にランタイム/メールフォルダに到着

public function actionTestmail() 
{ 
    Yii::$app 
     ->mailer 
     ->compose(['html' => 'courriel-test-html']   
     ) 
     ->setFrom("[email protected]") //->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot']) 
     ->setTo('[email protected]') 
     ->setSubject('Email for test purpose') 
     ->send(); 
    return $this->render('index'); 
} 

のindex.php

// comment out the following two lines when deployed to production 
//defined('YII_DEBUG') or define('YII_DEBUG', true); 
//defined('YII_ENV') or define('YII_ENV', 'dev'); 

require(__DIR__ . '/../vendor/autoload.php'); 
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); 

$config = require(__DIR__ . '/../config/web.php'); 

(new yii\web\Application($config))->run() 

;

のconfig/web.php

'Smtpmail'=>array(
       'class'=>'application.extensions.smtpmail.PHPMailer', 
       'useFileTransport' => false, 
       'Host'=>"fox.o2switch.net", 
       'Username'=>'[email protected]',//a valid account 
       'Password'=>'******',//the actual password for the account above 
       'Mailer'=>'smtp', 
       'Port'=>587, 
       'SMTPAuth'=>true, 
       'SMTPSecure' => 'tls', 
      ), 

or 

     'mailer' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'useFileTransport' => false, 
      'transport' => [ 
       'class' => 'Swift_SmtpTransport', 
       'host' => 'fox.o2switch.net', 
       'username' => '[email protected]', 
       'password' => '*******', 
       'port' => '25', 
       // 'encryption' => 'tls', 
      ], 
     ], 

どちらの場合も、結果は、実行時/メール内のファイルと同じですが、何のメールが実際に間違っている何 を送信されませんか?

答えて

0

私は私が最終的に をそれを作っ

0

configにライン

'useFileTransport' => false, 

は無用であると思われ、この

$mailer = Yii::$app->mailer; 
$mailer->useFileTransport = false; 
$mailer->compose… 

ようactionTestmail()関数を変更することによってそれを解決私は "useFileTransport => true"と書かれた設定で重複していました。

関連する問題