I am having problems sending emails using Yii2´s swiftmailer. I have tried using SMTP as well as PHP as transport, neither seem to be sending the emails.
These SMTP credentials work fine using swiftmailer with Yii 1.
According to the d0x, when I uncomment the transport property in my config, the default mail() function should be used. Mails are however still not being sent/received.
According to the Yii Debugger, the email is successfully sent (see attached image)
If I simply use php’s mail() function myself (without using swiftmailer), the email is sent and received fine.
Can anybody please help me out? I’m a noob and I havn’t the foggiest what to try.
/**
* @var boolean whether to save email messages as files under [[fileTransportPath]] instead of sending them
* to the actual recipients. This is usually used during development for debugging purpose.
* @see fileTransportPath
*/
public $useFileTransport = false;
/**
* @var string the directory where the email messages are saved when [[useFileTransport]] is true.
*/
I deployed last week Yii2 advanced application using Composer on a WAMP server.
I am also facing problems sending emails using SwiftMailer. I followed Yii2 documentation and I also added ‘useFileTransport’=>‘false’ as described in this post.
Unfortunately, even with this, the emails are not sent. Yii2 creates email files in /runtime/mail folder but doesn’t send the emails. I am not able to find any log reporting an error or a problem.
I searched through all project files to find an unexpected ‘useFileTransport’=>‘true’ but I was unable to find one.
Here is the content of my /common/config/main-local.php:
Question: for the name of the "email" component in the configuration file, sometimes we found "mail" and sometimes "mailer". Can we use both of them? As you can see in my config file, I used "mailer".
What I must to do, Install swiftmailer on the server? I can’t do that, there is only shared hosting.
Can I use mail function, how to configure mailer to work with it?
my config is:
'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,
],