Mail Can Not Send

Hi everybody!

I use yii\swiftmailer\Mailer and config as following:

‘components’ => [


'mail' => [

  'class' => 'yii\swiftmailer\Mailer',

  'transport' => [

    'class' => 'Swift_SmtpTransport',

    'host' => '',

    'username' => 'username',

    'password' => 'password',

    'port' => '587',

    'encryption' => 'tls',




I am using gmail account with username and password is exactly.My gmail account status is ok.





 ->setSubject('Email sent from Yii2-Swiftmailer')



But it has error 500.I can not sent mail.Why is the issue?Anybody has any ideas?Thanks

Try enabling YII_DEBUG in your index.php and checking logs. It should give you an idea.

Hi samdark.

Thank you for your reply.

I have checked log but i haven’t found any error or warning.But on web browser i see to have 1 error ‘Failed to load resource: the server responded with a status of 500 (Internal Server Error)’.

If if i comment code lines relate to mail, everything is ok.

I can’t understand about this.

500 (Internal Server Error) means your server is either replacing responses with 500 error with his own page or you have errors display turned off.

Thank samdark.

Problem solved? What was it?

Hi samdark!

I have been solving it.My server has a few issues i must face.

I will solve it in a few day.

Thank for your ask.