I am doing a project where I want a mail to be sent to a new user with a link for confirmation and after clicking that link then only he can access his profile. After many types of research, I am unable to find a proper answer on how to implement this in my project. I am using JSP and servlet for development in localhost. I hope here I will get the proper solution for my problem.
Asked
Active
Viewed 6,896 times
-1
-
check this url http://stackoverflow.com/questions/10545507/how-to-verify-user-clicked-on-link-in-email-that-i-sent-him-her – hicham abdedaime Feb 17 '17 at 12:59
1 Answers
1
Question is too broad.. In order to achieve your requirement we need to do multiple things
- Need smtp server
- Send Email though Java using smtp
- generate a unique key, encrypt it and add it to registration link (http://www.myxyz.com?sId=XXXXXXXXXXX) and save non-encrypted key in database (you need some kind of cross verification process)
- when user clicks link, grab the key and decrypt it and validate the key with key in database
In order to achieve item-2 follow http://www.javatpoint.com/example-of-sending-email-using-java-mail-api
I used following way to generate unique key (item-3)Efficient method to generate UUID String in JAVA (UUID.randomUUID().toString() without the dashes)
item-4: Implement logic on server side (Servlet is best option)

Community
- 1
- 1

RamPrakash
- 1,687
- 3
- 20
- 25
-
Do I have to create a new table for storing key related to confirmation? I have a contact form and also option to reset password. To implement this feature I need to send an email by Gmail server or any other way is also there? Studying about sending email by Gmail server: http://www.javatpoint.com/example-of-sending-email-using-java-mail-api-through-gmail-server – Dinesh Feb 17 '17 at 13:40
-
I have similar kind of application, i'm storing key in Database so that i could set expiration for each key. – RamPrakash Feb 17 '17 at 13:44
-
-
-
Have you shared your project in Github? I just want to have a look on how you implemented – Dinesh Feb 17 '17 at 13:56
-
@Dinesh I cannot share Code.. I shared my approach though answer.. If this solves your question then please accept answer. – RamPrakash Feb 17 '17 at 13:58
-
-
Better to have a table with userId , Unique key, email sent time, verified email time, email status.. Again it completely dpends on your application. – RamPrakash Feb 17 '17 at 14:07
-
@Dinesh if this is your expected answer for your question,,please accept the answer so that this question won't appear as unanswered. – RamPrakash Feb 20 '17 at 18:02