YII2-邮件始终保存为文件,但不发送,尽管useFileTransport=false
我试图从Yii2生产站点发送邮件,但邮件总是到达runtime/mail文件夹 这是控制器中的操作:YII2-邮件始终保存为文件,但不发送,尽管useFileTransport=false,yii2,mailer,Yii2,Mailer,我试图从Yii2生产站点发送邮件,但邮件总是到达runtime/mail文件夹 这是控制器中的操作: public function actionTestmail() { Yii::$app ->mailer ->compose(['html' => 'courriel-test-html'] ) ->setFrom("user@domain.fr") //->setFro
public function actionTestmail()
{
Yii::$app
->mailer
->compose(['html' => 'courriel-test-html']
)
->setFrom("user@domain.fr") //->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
->setTo('me@mydomain.com')
->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();
'Smtpmail'=>array(
'class'=>'application.extensions.smtpmail.PHPMailer',
'useFileTransport' => false,
'Host'=>"fox.o2switch.net",
'Username'=>'user@domain.fr',//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' => 'user@domain.fr',
'password' => '*******',
'port' => '25',
// 'encryption' => 'tls',
],
],
config/web.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();
'Smtpmail'=>array(
'class'=>'application.extensions.smtpmail.PHPMailer',
'useFileTransport' => false,
'Host'=>"fox.o2switch.net",
'Username'=>'user@domain.fr',//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' => 'user@domain.fr',
'password' => '*******',
'port' => '25',
// 'encryption' => 'tls',
],
],
在这两种情况下,结果是相同的,即运行时文件/mail,但实际上没有发送邮件。有什么问题吗?我通过如下更改actionTestmail()函数解决了这个问题
$mailer = Yii::$app->mailer;
$mailer->useFileTransport = false;
$mailer->compose…
似乎这条线
'useFileTransport' => false,
在配置中是无用的我通过如下更改actionTestmail()函数解决了这个问题
$mailer = Yii::$app->mailer;
$mailer->useFileTransport = false;
$mailer->compose…
似乎这条线
'useFileTransport' => false,
在配置中是没有用的我终于弄明白了
我在配置中有一个副本,上面写着“useFileTransport=>true,”
我在配置中有一个重复项,它声明“useFileTransport=>true,”