This extension provides a Symfony Mailer mail solution for Yii framework 2.0.
For license information check the LICENSE-file.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiisoft/yii2-symfonymailer
or add
"yiisoft/yii2-symfonymailer": "~2.0.0"
to the require section of your composer.json.
To use this extension, simply add the following code in your application configuration:
return [
//....
'components' => [
'mailer' => [
'class' => \yii\symfonymailer\Mailer::class,
'transport' => [
'scheme' => 'smtps',
'host' => '',
'username' => '',
'password' => '',
'port' => 465,
'dsn' => 'native://default',
],
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure transport
// for the mailer to send real emails.
'useFileTransport' => false,
],
],
];
or
return [
//....
'components' => [
'mailer' => [
'class' => \yii\symfonymailer\Mailer::class,
'transport' => [
'dsn' => 'smtp://user:[email protected]:25',
],
],
],
];
You can then send an email as follows:
Yii::$app->mailer->compose('contact/html')
->setFrom('[email protected]')
->setTo($form->email)
->setSubject($form->subject)
->send();