Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send activation email to user

Tags:

php

activation

How would I do to check if a email actially exists? Cant understand how sites do to send mails with a unique link that the users clicks to validate that he is the owner of email =/

Make a 2 new columns called activationkey and activated and store some random string, send an email with the activationkey, and update the users activated =1 that match that activation link

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

Any better ideas?

like image 310
Martin Avatar asked Jan 06 '10 22:01

Martin


2 Answers

I generally send a link that contains the userid, and the activation key. When they visit my activation script, if I find a match, I activate them.

When they register, I'll generate maybe 32 chars of upper/lower case alphanumeric characters and set it as the activation key. At this point, you can create a field called 'activated,' or you can assume the user is not activated if they have an activation key.

uid |        email       | key
------------------------------------------------------------
001 | [email protected] | e09141f3f5a17fed6222fc0279b9afdf
------------------------------------------------------------
002 | [email protected] | 
------------------------------------------------------------

When the user accesses the activation script, simply check for the provided key along with the provided id and if a match is found, erase the key from the user record on file (or update your boolean 'activated' field) and open the doors up.

If the provided email address doesn't exist, no loss. You can routinely remove all rows with keys after a month of inactivity.

like image 107
Sampson Avatar answered Sep 22 '22 23:09

Sampson


One alternative to activation keys is to just send a generated password to the user email, if the user logs in he is activated (and of course, should be able to change the password to what he prefers).

like image 24
Alix Axel Avatar answered Sep 21 '22 23:09

Alix Axel