Send activation letter to user

How do I do to check if email exists? I can’t understand how sites send mail with a unique link that users click to confirm that they own email = /

Create 2 new columns called activation and activate them and save some random row, send an email with the activation key and update the activated users = 1 corresponding to this activation link

register.php?a=activate&key=9cdfb439c7876e703e307864c9167a15 

Any better ideas?

+6
php activation
source share
3 answers

Usually I send a link containing the user ID and activation key. When they visit my activation script, if I find a match, I activate them.

When they are registered, I will probably generate 32 characters of alphanumeric upper and lower case letters and set it as an activation key. At this point, you can create an “activated” field, or you can assume that the user is not activated if he has an activation key.

  uid |  email |  key
 -------------------------------------------------- ----------
 001 |  j.smith@mysite.com |  e09141f3f5a17fed6222fc0279b9afdf
 -------------------------------------------------- ----------
 002 |  mary.tyler@abc.com | 
 -------------------------------------------------- ----------

When the user accesses the activation script, simply check the provided key with the provided identifier, and if a match is found, remove the key from the user record in the file (or update the “activated” logical field) and open the door up.

If the email address provided does not exist, no loss. You can regularly delete all rows with keys after a month of inactivity.

+16
source share

One alternative to the activation keys is simply to send the generated password to the user's email address, if the user logs into the system, he is activated (and, of course, should be able to change the password to what he prefers).

+2
source share

There is no easy way to check if a letter really exists. There are several ways (pinging mailserver, etc.), but it has not been proven that they work with each setting of the mail server. Forcing a user to activate their account via a link as you described is the best way to do this. In addition, you may want to have some kind of repeating script as a cron job that removes inactive elements after a certain period of time (which will require another column in your table, a timestamp).

This is useful because if a user signs up, but never activates their account and does not delete the email, and you use your email as an identifier (just an example), they will never be able to complete the activation. Otherwise, if they try to log in, you can simply resend the activation email to this address.

Just make sure that you include all the headers in the email (reply, from, etc.), so your email is not marked as spam.

0
source share

All Articles