Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email address validation methods (Subscribe button)

I am coding a site in php and I am currently on the contact us page and I was wondering what was the best way to validate an email address?

  1. By sending a validation link to their email?
  2. Regex
  3. Any other method?

Also could you tell me why and a guide along my way to achieving it? I dont want someone to do the code for me because thats no fun for me and I won't learn but just some guidance on the techniques used to achieve either the methods above.

Also I am going to use these methods to implement a subscribe button on my webpage. Is this the best way to do this? any other methods I should condsider?

like image 423
RSM Avatar asked Jul 15 '10 07:07

RSM


2 Answers

I usually go through these steps

  1. Regex
  2. Send an activation code to the email

if the first step fails it never reaches second step. if the email sending fails because the email doesn't exist I delete the account or do some other stuff

--edit

3 - If for some reason the activation email doesn't get sent, email doesn't get deleted, it stays unapproved for 7 days (or as configured by you), email resending is tried in every 2-3 hours, after those days if no success, email is deleted

4 - If email sent successfully but not activated it stays unapproved but can be reactivated anytime by generating a new activation code

like image 140
Flakron Bytyqi Avatar answered Oct 01 '22 08:10

Flakron Bytyqi


I think the best is a combination of 3. and 1.

In an initial phase you verify syntactically the e-mail (to catch typos):

filter_var($email, FILTER_VALIDATE_EMAIL)

And in a second one you send an e-mail with a confirmation address (to both catch errors and deliberately wrong information).

like image 39
Artefacto Avatar answered Oct 01 '22 10:10

Artefacto