Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

siangboon's avatar

i not so sure.. but mail client may have their own engine and own way to solve the issue automatically.... such as setup a mail account in Microsoft Outlook, we just need to key in the email address and password, it help to resolve the mail host and everything... perhaps, thunderbird will help to resolve and appending the domain at the username automatically if not a full email address in used, i guess... Hence, telnet with SMTP command can help to identify it.

RamjithAp's avatar

@loomix Please follow the below steps. Ignore if already done.

  1. Go to https://www.smtper.net/ and test your SMTP credentials and use the same which works there.
  2. Configure .env and mail.php properly means use the correct variable names. For example dont use env('xyxyx') in mail.php change that to env('USERNAME') then in your .env file USERNAME=xyxyx.
  3. Finally, if the error comes, post the complete error in your log file here to help.(Replace credentials in error log before post)
1 like
Loomix's avatar

@ramjithap

.env:

MAIL_DRIVER=smtp
MAIL_HOST=###.netcup.net
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=#########
[email protected]
MAIL_FROM_NAME="me"
MAIL_ENCRYPTION=ssl

config/mail.php:

return [
    'default' => env('MAIL_MAILER', 'smtp'),
    'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', '###.netcup.net'),
            'port' => env('MAIL_PORT', 465),
            'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),   
            'timeout' => null,
            'auth_mode' => null,
        ],
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'me'),
    ],
    'markdown' => [
        'theme' => 'default',
        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
];

Error in Laravel (same for port 25 and mail_encryption=null):

[2020-05-11 12:56:35] local.ERROR: Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators. Authenticator CRAM-MD5 returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
". Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
". {"exception":"[object] (Swift_TransportException(code: 0): Failed to authenticate on SMTP server with username \"[email protected]\" using 3 possible authenticators. Authenticator CRAM-MD5 returned Expected response code 235 but got code \"535\", with message \"535 5.7.8 Error: authentication failed: authentication failure

smtper works fine and sends me:

This mail was directly sent by ###.netcup.net.

SMTP host: ###.netcup.net
Port: 465
Use SLL: True
Use Authentication: True
Authentication name: [email protected]
Authentication password: [not applicable]
Email from: [email protected]
Email to: [email protected]


This service is provided by https://www.smtper.net
Snapey's avatar
Snapey
Best Answer
Level 122

I know you don't want to hear from me, but its worth passing on a small tip. If your password contains a # then all the characters after it are treated as comment. For this reason, you should get in the habit of quoting passwords in your .env file.

1 like
RamjithAp's avatar

@snapey made a good point. So cover your password in .env if it has # character like this "Test#123". Then post the results.

Loomix's avatar

I tested several accounts and all passwords contained a # indeed, so this was the issue for Laravel. I can't believe this was the problem. It cost me 2 days and almost got me insane. Isn't Laravel supposed to handle this?

I just checked the vanilla install of Laravel 7 and the only line which is quoted by default is MAIL_FROM_NAME, the other are plain and work as plain -- except MAIL_PASSWORD. This is not fair, really.

Snapey's avatar

Its a failing of dotenv really, and the .env file format. Hashes in lines denote the start of a comment.

tranthaihoang's avatar

I also got the same error, before that I used gmail's smtp and my personal sendgrid it worked fine. But the client's account gave me it's error like this topic!

Previous

Please or to participate in this conversation.