Framework: Bad domains not being handled in registration flow when email verification is required

Created on 29 May 2020  路  3Comments  路  Source: laravel/framework


Description:

When a user signs up with an email and enters a domain that is invalid, an error is thrown by Mailgun when the verification emails are to be sent, see below

Client error: POST https://api.mailgun.net/v3/...removed.../messages.mime resulted in a 400 BAD REQUEST response: { "message": "'to' parameter is not a valid address. please check documentation" }

This stops the app dead in its tracks.

Steps To Reproduce:

  1. Enter an email with a domain that does not exist (for example: [email protected])
  2. User record is created and the email and password can be used, but
  3. Verification email flow is kicked off and throws error above

Most helpful comment

Since that previous issue thread, Laravel added new email validation options: https://laravel.com/docs/7.x/validation#rule-email

Applications can update RegisterController@validator() to:

'email' => ['required', 'string', 'email:rfc,dns', 'max:255', 'unique:users'],

Invalid domains will cause the form submission to fail before saving to the database and making a Mailgun request.

All 3 comments

Since that previous issue thread, Laravel added new email validation options: https://laravel.com/docs/7.x/validation#rule-email

Applications can update RegisterController@validator() to:

'email' => ['required', 'string', 'email:rfc,dns', 'max:255', 'unique:users'],

Invalid domains will cause the form submission to fail before saving to the database and making a Mailgun request.

Since that previous issue thread, Laravel added new email validation options: https://laravel.com/docs/7.x/validation#rule-email

Applications can update RegisterController@validator() to:

'email' => ['required', 'string', 'email:rfc,dns', 'max:255', 'unique:users'],

Invalid domains will cause the form submission to fail before saving to the database and making a Mailgun request.

Thanks! Have been holding off on upgrading but glad to know that there are additional validation rules to cover that case.

Since that previous issue thread, Laravel added new email validation options: https://laravel.com/docs/7.x/validation#rule-email

Applications can update RegisterController@validator() to:

'email' => ['required', 'string', 'email:rfc,dns', 'max:255', 'unique:users'],

Invalid domains will cause the form submission to fail before saving to the database and making a Mailgun request.

You are awesome, your comment fixed my problem, thanks :)

Was this page helpful?
0 / 5 - 0 ratings