PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 20, 2022

[FIXED] Yii swiftmailer fails to work in live server

 February 20, 2022     php, swiftmailer, yii, yii2     No comments   

Issue

Am using yii2 and i have setup a mailer as follows

  <?php
  return [
   'components' => [
  ....
    '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' => false,
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'myemail@gmail.com',
            'password' => 'mygmailpassword',
            'port' => '465',
            'encryption' => 'ssl',
        ],
    ],
],

];

The above works perfectly in localhost but fails when i upload to the live server i always get an error of bad credentials

The error is

Swift_TransportException

 Expected response code 250 but got code "535", with message "535-5.7.8     
Username and Password not accepted. Learn more at

535 5.7.8 https://support.google.com/mail/?p=BadCredentials 
r199sm3707144wme.1 - gsmtp

"

What could be wrong,


Solution

I use this config for gmail (and work)

        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'myname.mylast@gmail.com',
            'password' => 'mypass',
            'port' => '587',
            'encryption' => 'tls',
        ],


Answered By - ScaisEdge
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing