如何验证用户点击我发送给他/她的电子邮件中的链接? [英] how to verify user clicked on link in email that I sent him/her?

查看:363
本文介绍了如何验证用户点击我发送给他/她的电子邮件中的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个更集中的问题,由以前在这里发布。我需要通过证明他/她有权访问用户的电子邮件地址。我已经下载了您在加入开发者论坛或用户组时期望看到的通用电子邮件身份验证。作为注册过程的一部分,您可以提供您的电子邮件地址,然后您会收到一封电子邮件,要求您单击确认您的电子邮件地址。

This is a more focused question triggered by an earlier posting here. I need to authenticate a user's email address by proving he/she has access to it. I've copied below a generic email authentication you'd expect to see when joining a developer forum or user group. As part of the registration process, you'd provide your email address, and then you'd get an email asking you to click on something to verify your email address.

当用户点击电子邮件中的链接时,我需要编写代码。所以我的问题是 - 我该如何做?

I need to code whatever happens when a user clicks on the link in the email. So my question is -- how do I do that?

涉及哪些技术?任何人都可以走过我的步骤吗?我喜欢Java或Linux脚本语言,如bash。更好的是,是否有为此开发的软件,我可以在我的Linux服务器上安装,并以某种方式将其与我的数据库进行交流?这在实践中如何完成?如果它已经可用,我不想重新发明一些东西。

What technologies are involved? Can anyone walk me through the steps? I prefer Java or Linux scripting language like bash. Better yet, is there any software developed for this purpose I can install on my Linux server and somehow integrate it to talk with my database? How is this done in practice? I don't want to reinvent something if it's already available.

To confirm your email address of: 

youremail@yourdomain.net 

please send a short reply to this address: 

users-sc.1496854427.ckdpbmhncdlkjadkajfpecc-mylist=yourdomain.net@listdomain.com 

Usually, this happens when you just hit the "reply" button. 
If this does not work, simply copy the address and paste it into 
the "To:" field of a new message. 

or click here: 
mailto:users-sc.1496854427.ckdpbmhncdlkjadkajfpecc-mylist=yourdomain.net@listdomain.com  

This confirmation serves two purposes. First, it verifies that I am able 
to get mail through to you. Second, it protects you in case someone 
forges a subscription request in your name. 

Some mail programs are broken and cannot handle long addresses. If you 
cannot reply to this request, instead send a message to 
<users-request@listdomain.com> and put the 
entire address listed above into the "Subject:" line. 


推荐答案

在您的用户数据库中,您需要有一个登台用户表(或在主用户表中添加一列,指示用户是否处于活动状态,并将该指示器默认为否)。当用户首次注册时,您可以从用户信息的一部分生成唯一的哈希码,例如。在用户主键和名称(或某些其他一组用户的变量,您可以通过解密恢复)使用md5)。在发送给用户的链接中使此哈希码成为查询字符串参数。最后,当用户点击链接时,从查询字符串获取哈希码,将其解密并将解密的值与数据库中的用户行进行匹配。如果找到匹配项,将活动指示器设置为true,然后将其设置为presto。或者,如果您使用暂存表,请将用户记录移动到用于执行授权的活动用户表。

In your user database you need to have a staging users table (or in the main users table add a column indicating whether the user is active and default the indicator to "no"). When the user first registers, you generate a unique hash code from part of the user's info, e.g. Use md5 on user primary key and name (or some other set of user's variables which you can get back by decrypting) . Make this hash code a query string parameter in the link you send to the user. Finally, when the user clicks on the link, get the hashcode from the query string, decrypt it and match the decrypted values to the user row in your database. If a match is found, set the "active" indicator to true, and presto. Alternately, if you used a staging table, then move the user record to the "active users" table which you use to do your authorization on.

这篇关于如何验证用户点击我发送给他/她的电子邮件中的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆