S
S
Sergey2015-03-10 04:38:30
Yii
Sergey, 2015-03-10 04:38:30

How to set up mailer to work via mail() and not swiftmailer in yii2?

What should be done for this?
Here is my code and it doesn't work:

Yii::$app->mailer->compose()
            ->setTo('[email protected]')
            ->setFrom('[email protected]')
            ->setSubject('Invite')
            ->setTextBody('Hello!')
            ->send();

I don't see emails in my inbox.
But if I send it manually via mail() - everything is ok.
Instead of writing my own method, can I set up mailer to work via mail()?
How to do it?
If there is no way through mail, then how to get this swiftmailer, should it be installed on the server? And if shared hosting, then everything, no way?
Now the settings are default.
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// 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' => false,
],

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sanex3339, 2015-03-10
@butteff

Off the dock says that
www.yiiframework.com/doc-2.0/yii-swiftmailer-maile...

C
chesar, 2015-03-10
@chesar

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@app/views/mail',
            'transport' => [
                'class' => 'Swift_MailTransport',
            ],
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question