相关文章推荐
坏坏的山羊  ·  SpringBoot2.X ...·  2 月前    · 
私奔的火车  ·  Clear 方法 (Visual ...·  1 年前    · 
仗义的大蒜  ·  TS 中 never,void,unknow ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 Authentication failed"."

Ask Question

i got an error when trying to send an email using laravel auth.

this is my .env file

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=465
MAIL_USERNAME=myEmail@gmail.com
MAIL_PASSWORD=myPassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello@example.com
MAIL_FROM_NAME=Example

and this is my mail.php file

    'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            'port' => env('MAIL_PORT', 465),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
        'ses' => [
            'transport' => 'ses',
        'mailgun' => [
            'transport' => 'mailgun',
        'postmark' => [
            'transport' => 'postmark',
        'sendmail' => [
            'transport' => 'sendmail',
            'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
        'log' => [
            'transport' => 'log',
            'channel' => env('MAIL_LOG_CHANNEL'),
        'array' => [
            'transport' => 'array',
        'failover' => [
            'transport' => 'failover',
            'mailers' => [
                'smtp',
                'log',
    |--------------------------------------------------------------------------
    | Global "From" Address
    |--------------------------------------------------------------------------
    | You may wish for all e-mails sent by your application to be sent from
    | the same address. Here, you may specify a name and address that is
    | used globally for all e-mails that are sent by your application.
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    |--------------------------------------------------------------------------
    | Markdown Mail Settings
    |--------------------------------------------------------------------------
    | If you are using Markdown based email rendering, you may configure your
    | theme and component paths here, allowing you to customize the design
    | of the emails. Or, you may simply stick with the Laravel defaults!
    'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),

I've tried changing the value of MAIL_MAILER, MAIL_HOST,MAIL_PORT, MAIL_ENCRYPTION, MAIL_FROM_ADDRESS, and MAIL_FROM_NAME in .env file according to the information in the mail.php file. but it's still didn't work.Can someone please help me to resolve this, thank you.

MAIL_HOST=smtp.mailgun.org MAIL_PORT=465 MAIL_USERNAME=myEmail@gmail.com \\ Gmail mail iD MAIL_PASSWORD=myPassword \\ Gmail App generated password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=hello@example.com MAIL_FROM_NAME=Example

Below link to generating an app password. https://support.google.com/mail/answer/185833?hl=en

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mygmail@gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls

Localhost system MAIL_DRIVER=smtp was working fine, when you uploaded your project on cpanel then getting this error. So simple change in .env file

MAIL_DRIVER from smtp to sendmail.

More help also read: The connection could not be established with host smtp.gmail.com?

How to Send Email in Laravel with Example?

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.