Reputation: 1902
I'm new on Laravel and I'm trying to configure mail. My .env file is configurated as:
MAIL_DRIVER=SMTP
MAIL_HOST=vserv.******.***
MAIL_PORT=587
MAIL_USERNAME=admin@******.***
MAIL_PASSWORD=********* <--- (9 chars lengh)
MAIL_ENCRYPTION=TLS
For my mail test I'm using tinker:
>php artisan tinker
>>> Mail::send('mails.contact',[], function($message) { $message->to('sergio@******.****')->subject('Testing email'); });
Before testing I flush the cache as:
>php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!
Tinker return this error:
Swift_TransportException with message 'Failed to authenticate on SMTP server with username "admin@******.***" using 3 possible authenticators. Authenticator CRAM-MD5 returned Swift_TransportException: Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
" in ****/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:457
Server side, mail log has the error:
Mar 14 16:47:13 vserv plesk_saslauthd[21227]: failed mail authenticatication attempt for user 'admin@******.***' (password len=8)
note: the password I used in env is 9 chars but in error message is always 1 char less! If I type a wrong password 10chars length the error show (password len=9) and so on. Does it make sense?
Thanks for any suggestion.
Upvotes: 2
Views: 2058
Reputation: 5552
The error indicates that your username or password is wrong. In this case there is a #
character in the password string, which causes the rest of the password to be interpreted as a comment.
The solution is to quote the password:
MAIL_PASSWORD="my#secret"
If it used to work and doesn't anymore, it might be because Laravel 5.8 included an updated version of the dotenv library which changed the behavior:
https://laracasts.com/discuss/channels/laravel/beware-in-env-files
Upvotes: 4