简体   繁体   English

在注册用户之前发送验证邮件 - PHP

[英]Sending verification mail before registering user - PHP

I am currently working on the PHP project in which I have to send the verification mail to the user who register in the site.我目前正在处理 PHP 项目,在该项目中我必须向在该站点中注册的用户发送验证邮件。 (Email id is the username). (电子邮件 ID 是用户名)。 I am having the following doubt.我有以下疑问。

  • Whether I have to send them the verification email before storing the user in database or after storing the user in database.我是否必须在将用户存储在数据库之前或将用户存储在数据库之后向他们发送验证电子邮件。
  • If I send the verification mail to the user after storing user in database what I have to do if the email is not sent from my server.如果我在将用户存储在数据库中后将验证邮件发送给用户,如果电子邮件不是从我的服务器发送,我必须做什么。 Because user cannot able to re-register with the same email id.因为用户无法使用相同的电子邮件 ID 重新注册。

Please help me in this problem.请帮我解决这个问题。 Thanks in advance提前致谢

  • you have to send mail after registration save details in db with key(that will send with link) and status like 0 in database .您必须在注册后发送邮件,使用密钥(将通过链接发送)和数据库中的 0 等状态保存在数据库中的详细信息。 if they click on that link then delete activation key from database and also change status into 1 and on login you also need to check user have status 1 if not then you can show alert like Mail Confirmation Pending .如果他们单击该链接,然后从数据库中删除激活密钥,并将状态更改为 1,并且在登录时您还需要检查用户的状态为 1,否则您可以显示类似 Mail Confirmation Pending 的警报。

  • after send mail you can check mail sent or not .check this question发送邮件后,您可以检查邮件是否已发送。检查此问题

I suggest you store the user in database and then send the verification email.我建议您将用户存储在数据库中,然后发送验证电子邮件。 In the database keep a field to mark whether user verified the email or not.在数据库中保留一个字段来标记用户是否验证了电子邮件。

Give user an option to resend email verification incase they didn't receive.为用户提供重新发送电子邮件验证的选项,以防他们没有收到。

As far as from my experience就我的经验而言

  1. Enter details in DB and then send the verification mail, else your in a situation that you cant verify the user back again.在数据库中输入详细信息,然后发送验证邮件,否则您将无法再次验证用户。

  2. In-case email sending fails from your side, provide a option for the user to request for resending of the verification mail.如果您的电子邮件发送失败,请为用户提供一个选项以请求重新发送验证邮件。

  3. Maintain a status in the DB whether a user is verified or not, and based on that you can resend the verification mail.无论用户是否被验证,在数据库中维护一个状态,并基于此您可以重新发送验证邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM