@loomix check the mail address your are sending to is a valid email address. It looks like the problem is that you try sending an email to a non-existing or non-valid email address
"554 5.5.1 Error: no valid recipients" on password reset
I just installed a fresh Laravel with laravel new projectname --auth to test this on a clean install:
The pw reset function gives me Swift_TransportException: Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients ". So I tested and verified the credentials of 3 different mailaccounts (from 3 different providers) and they all work fine for sending mails in Thunderbird but not in Laravel, so I guess the data for my mailaccounts is fine. I also tested my googlemail account which also works fine but throws the same error in Laravel.
My config/mail.php:
return [
'default' => env('MAIL_MAILER', 'smtp'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'w01199f1.xxxserver.com'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'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', 'xxx'),
],
];
My .env:
MAIL_DRIVER=smtp
MAIL_HOST=w01199f1.xxxxerver.com
MAIL_PORT=587
MAIL_USERNAME=mx5xxxe41
MAIL_PASSWORD=xxxxxx
[email protected]
MAIL_FROM_NAME="xxx"
MAIL_ENCRYPTION=tls
Maybe it's because I am developing on localhost with WAMP and there's something I need to configure before I can send mails from my localhost Laravel app? Like I said, this is all vanilla Laravel install from today. Can anyone tell me why pw reset throws this error? Thanks.
Error says invalid recipient which means the to address you are trying to send is not correctly passed to mail class. Try log the to address before you send and check it is correctly coming.
@denniseilander The to address is my private mailaddress which is in daily use and working fine. It is also in the database Laravel uses and a token is correctly created in table password_resets. I also registered and tried some other Mailaddreses of mine and it's all the same error. I am pretty sure this is not about the recipient address, even if the error says so.
@ramjithap Could you give me a hint to what you exactly mean by "Try log the to address before you send and check it is correctly coming" and how to do that? Thanks
Open laravel.log and dig into that particular error. Every error will have 40 to 50 lines of description so in that email recipient and other details will be there in array format. So check recipient email present there correctly.
There are numerous lines of Swiftmailer, telling me nothing but I guess the first line gives it away: 'local.ERROR: Failed to authenticate on SMTP server with username "mx5xxxe41" using 2 possible authenticators.
and
Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6'
The thing is that I have tested several accounts and they all work well outside Laravel. I have no idea why it says that username is invalid, it is certainly not. I also have no idea what UGFzc3dvcmQ6 is, that is not my password or anything. Is it possible that my request from localhost is blocked by the mail provider or something like that?
@loomix I noted the following lines in your mail.php file:
'username' => env('mx5xxxe41'),
'password' => env('xxxxxxx')
This env() function should not receive the actual credentials but the config name in your env file
so it should look like this in your config/mail.php;
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD')
Your SMTP config mail username use full email address and try. Also update
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
@denniseilander I just tested it and of course it makes no difference since the env functions just refer to the settings in .env. Same error.
@ramjithap The config mail username is 'username' => env('mx5xxxe41'), so not a full mailaddress. Did you mix it up with the from address?
No both from address and username has to be full email address. Did you tested this smtp details on outlook or something? Is it working?
@ramjithap I just tried the full address as username and it is the same error. Yes, I tried this and other accounts in Thunderbird and all work fine. My googlemail account does not work also. All give the same error in Laravel.
From Laravel's documentation:
env()
The env function retrieves the value of an environment variable or returns a default value:
$env = env('APP_ENV');
// Returns 'production' if APP_ENV is not set...
$env = env('APP_ENV', 'production');
When you set this in your config file 'username' => env('mx5xxxe41') you're saying that the username value should equal an enviroment variable (a key on the .env file) called "mx5xxxe41".
Moreover, you're hardcoding a password on a configuration file that should be tied to a particular enviroment.
If you using Google mail for laravel you need to enable less secure apps permission on your google account.
@loomix what I mean is that you directly entered the username/password in the env() function like this:
'username' => env('mx5xxxe41'),
'password' => env('xxxxxxx')
But this won't work, you have to refer to the env variable file instead of passing the credentials directly.
@guybrush_threepwood That is true. The hardcoding was done when testing, you are absolutely right, though. Nevertheless the result is the same error.
@ramjithap I will try my googleaccount lateron. Still the others done work.
I just looked into Thunderbird and it says it's STARTTLS, not TLS. Just entered this in the mail.php and .env and now there is another error message:
Connection could not be established with host w01199f1.kasserver.com :stream_socket_client(): unable to connect to starttls://w01199f1.kasserver.com:587 (Unable to find the socket transport "starttls" - did you forget to enable it when you configured PHP?)
bear in mind that the email address and the password are only applicable to the server you have set in the smtp host. You cannot authenticate to MAIL_HOST=w01199f1.xxxxerver.com with your username or password. This needs to be the address of the relevant mail server.
@denniseilander is correct about the way you have specified username and password. Don't just dismiss this thinking you know better
@snapey It's the same server, I just x'd it out in my former post.
So all the mail accounts are on this same server... including the gmail one?
No, they are not. Totally different providers.
So, you are changing the host as well as the username and password when you test these different addresses.
If thats the case, then it must be the incorrect specification of username and password in your mail.php as suggested by @denniseilander
@loomix a tip to make sure the connection is set up correctly is to connect to https://mailtrap.io/ for example. If that connection works, then you have configured the settings with the wrong credentials of your own mail host/provider.
@snapey "It must be"? You are jumping to conclusions. I tested a lot today, with many different specifications and I don't think just repeating what someone else already pointed out and produces still the same error helps anything. Is there anything you can say about the error message I just posted?
@denniseilander I just tested it and of course it makes no difference since the env functions just refer to the settings in .env. Same error.
what rubbish
The env helper needs the name of the element in the env file not your actual username and password
You seem unclear exactly what the error message is, citing three different error messages.
Try erasing the log file, send the password reset email then post the log file here
I did see mail server which use username instead of full email address for authentication, but that is in a private enterprise mail server such as Microsoft Exchange or any mail server with LDAP... so far, i rarely see any 3rd party mail server allow user to use username to login....
first of all, i will try mailtrap.io first to ensure the email service in laravel is working accordingly.
then, i would try pure SMTP command using telnet... to clarify whether to use username or email address and try send an test message also. https://www.ndchost.com/wiki/mail/test-smtp-auth-telnet
if success, then only try different value of encryption (null, tls, starttls)
I found this thread and regarding the error message I posted the reason for the error seems to be the TLS / STARTTLS issue which is unsolved yet: https://laracasts.com/discuss/channels/servers/unable-to-find-socket-transport-starttls
Kinda funny but also frustrating how everyone kept suspecting wrong credentials while I said numerous times they are correct. I will now set up my googlemail account with enable less secure apps (like @ramjithap said) and work with that until there is further info on this TLS / STARTTLS issue.
@loomix if you are sure that your credentials are correct and you setup your configuration the right way, you should either give us (the community) the right information or update your code snippets, because there were several issues in your code snippets which gave us the idea this was the error/problem.
Otherwise it is hard to help you solving the problem.
@snapey Stop insulting me and stop commenting on my posts. Just because I am Level 1 here(!) does not mean I am an idiot. There is not the slightest contribution to this thread from your side. You're jumping to conclusions and repeat what others already said. I reported your disrespectful behaviour. Now go and get your points elsewhere.
@siangboon Thank you, I will try that. Best advice I read here.
Kinda funny but also frustrating how everyone kept suspecting wrong credentials while I said numerous times they are correct.
We did not say that they were incorrect, just the way you are passing them to the mail config
And there is no issue with TLS /STARTTLS I have lots of applications to a wide variety of smtp servers.
But anyway, you've backed yourself into a corner now, so good luck.
local.ERROR: Failed to authenticate on SMTP server with username "mx5xxxe41" using 2 possible authenticators.
Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6'
it's not we suspecting... it's the system telling so...
220 dd34130.kasserver.com ESMTP
>EHLO mailserver.com
250-dd34130.kasserver.com
250-PIPELINING
250-SIZE 102400000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
>AUTH LOGIN
334 VXNlcm5hbWU6
>bXg1eHh4ZTQx334
UGFzc3dvcmQ6
cGFzc3dvcmQ=535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6
exit
02 5.5.2 Error: command not recognized
421 4.4.2 dd34130.kasserver.com Error: timeout exceeded
Connection to host lost.
@siangboon So why do they work in other Mailers, e.g. Thunderbird? "mx5xxxe41" is not my username, I x'd it out, of course.
Please or to participate in this conversation.