Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email Verification invalid Domain in Email #26246

Closed
iPaat opened this issue Oct 25, 2018 · 17 comments
Closed

Email Verification invalid Domain in Email #26246

iPaat opened this issue Oct 25, 2018 · 17 comments

Comments

@iPaat
Copy link

iPaat commented Oct 25, 2018

  • Laravel Version: 5.7.9
  • PHP Version: 7.2.10
  • Database Driver & Version: mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64)

Description:

If email verification is enabled, the site breaks if an email with a none registered domain is entered.

Swift_TransportException (554)
Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients "

You could overwrite the sendEmailVerificationNotification method and wrap the everything within a try catch block.

public function sendEmailVerificationNotification()
{
    $verifyEmail = new VerifyEmail($this);
    try {
        Mail::to($this->email)
            ->send($verifyEmail);
    } catch (Swift_TransportException $e) {
        //
    }
}

But then it happens that the user is stuck into an endless loop where the user receives a massage that the email should be verified after login. But the user can't, because the email ist not send due to for example a typo the user made.

It is not even possible to redirect the user to another page since sendEmailVerificationNotification() is called after the user has been registered through the Illuminate\Auth\Events\Registered event.

Does someone have a workaround for this issue?

Steps To Reproduce:

  1. Enable E-Mail Verification
  2. Head to https://DOMAIN.TLD/register
  3. Lets assume that your E-Mail address is tim@hallotim.de but you made a misstake and type tim@hellotim.de as E-Mail address (this domain is not registered).
  4. Hit the send button.
  5. The site crashes.
@iPaat iPaat changed the title Email Verification Email Verification invalid Domain in Email Oct 25, 2018
@ghost
Copy link

ghost commented Oct 29, 2018

What's the actual value of $this->email?

@markszymik
Copy link

Got the same problem when sending mail notification:

Notification::route('mail', 'xxx@gmail.com')->notify(new App\Notifications\InvoiceOrder($sc));

@iPaat
Copy link
Author

iPaat commented Oct 30, 2018

What's the actual value of $this->email?

$this->email is in my case tim@hallotim.de.

@ghost
Copy link

ghost commented Oct 30, 2018

The problem is that hallotim.de is not a registered domain so you can't send an email to this address.. I don't think it's a bug.

@iPaat
Copy link
Author

iPaat commented Oct 30, 2018 via email

@driesvints
Copy link
Member

Sounds to me that this is more a user land error than an actual problem with the framework. You can catch the Swift_TransportException error yourself and handle it in your own codebase.

@rip057
Copy link

rip057 commented Jan 20, 2019

what i did is add a small [Wrong eMail?] button to the array that has the login and wrong password
screenshot_2019-01-20_09-49-42

@K-Kadosh
Copy link

K-Kadosh commented May 8, 2019

It looks like I do have the same issue, even with try{}catch(Swift_TransportException $sft){} the exception is not handled and it crashes.

@rip057
Copy link

rip057 commented May 8, 2019

My mailer doesn't throw an error immediately, as the relay accepts the outgoing address but then bounces it unless it is a local email, this is because the outgoing mailer tries the lookup, the address given, double bounces and returns to the postmaster for non-delivery notification. This is again why I put a box in the login if someone is awaiting verification, but hasn't clicked on the email, and logins, I return them to the login with a flash notification of the previous email, that the server will resend, and included now with the login and password, is a new email box, which upon correctly entering login and password and new email, a new verification email is sent and the email is updated. I also handle the mailer exception if one is thrown on the registration page.

@iPaat
Copy link
Author

iPaat commented May 10, 2019

@driesvints Could you please reopen this issue? The problem also seems to affect others and has been prematurely closed.

@rip057
Copy link

rip057 commented May 10, 2019

The requirement for the issue is parable 5.7.9 or higher...

Have you guys seen this
https://laravel.com/docs/5.8/verification

New email validation mechanism for laravel >=5.8.

Seems they have added a new class to the auth folder that standardizes a way to do this, and have included a new view type blade template for the mail, as well as having included it as a contract in the app\user model

I still like my very inconvenient reminder of the email address that is unverified by flash message, and including a "wrong email?" button next to the forgot password button, that opens an input field nezt to the username/pw boxes for the new email, and upon validation of user/PS the new email is stored and validation resent to the new address.

@K-Kadosh
Copy link

@rip057 It doesn't matter since in some case the mail server will return an error if the e-mail address is misspelled even if the e-mail address specified looks correct and respects standards.

The error thrown by this, can't be handled. That's the issue, at least for me.

@driesvints
Copy link
Member

We don't consider this a bug. If we catch the exception ourselves and handle it then people who would want to handle it differently are left in the dark. You're free to handle the exception how you want to yourself.

@Richard2012
Copy link

Richard2012 commented Jan 1, 2020

I am getting the same

Swift_TransportException (554)
Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients "

error on 5.8 version.
I have entered a correct, existing email address from the users table using SMTP driver and complete, correct credentials in .env and in config/mail.php.
I could not catch the exception myself because I did not write any code. The error is generated in the Laravel native /password/reset route (Auth password renewal).
Update: the issue has nothing to do with the email server, because the same error appears if I put a wrong email password in the .env file
2. Update: we did a new installation of Laravel 6 in a new environment, following the examples from the documentation. The database has been created by artisan migrate (except the 191 character fix). We can register new users, log in, log out, but as soon as we fill the "password forgotten" email form exactly the same error pops up on the /password/email url.
SOLVED
The problem was in the /config.mail.php
We wrongly had

    'username' => env('m2222222'),
    'password' => env('pwdpwdpwd'),

and that changed to

    'username' => env('MAIL_USERNAME','m2222222'),
    'password' => env('MAIL_PASSWORD','pwdpwdpwd'),

All fine now.

@ltphen
Copy link

ltphen commented Apr 18, 2020

Hello I have the same problem. All is correct but I receive this message. I don't known why Swift_TransportException
Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients
"

@whollaus
Copy link

@ltphen Have you solved the problem? It's the same for me. E-mail sending works. But if the recipient's address is wrong (but valid) this error will be displayed.

@Richard2012
Copy link

Richard2012 commented Apr 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants