To enable sending mail from your YII2 application using PHP mail function, make the following adjustment in the YII2 config file.
Find the following:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// 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.
'useFileTransport' => true,
],
This will be under the components parameters in the config. If using advanced YII2 instance, the file will be in common/main-local.php by default.
Change the code to this:
return [
'components' => [
...
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
'transport' => [
'class' => 'Swift_MailTransport',
],
'useFileTransport' => false,
],
],
];
useFileTransport must be changed to false and transport is set to use Swift_MailTransport.
See the following site for info on swiftmailer transport types.
http://swiftmailer.org/docs/sending.html#using-the-mail-transport