Search code examples
phpvalidationemailsubscription

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?


Solution

  • 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