1
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()
;
설정 두 경우 모두/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',
],
],
이 결과는, 실행/메일에서 파일 동일하지만 메일은 실제로 무엇이 잘못을 전송되지?