通过电子邮件和电子邮件进行电子邮件验证PHP?
我在某些网站上看到,用户可以简单地将空白电子邮件发送到类似 [ email protected] 如果他们在获取验证电子邮件时遇到问题,请验证他们的电子邮件。我有一个使用 PHP/MySQL 的网站,我想实现同样的功能,但除了发送电子邮件之外,我没有对电子邮件做太多事情,所以我什至不知道从哪里开始设置这样的东西。
I have seen on some sites where the user can simply send a blank e-mail to something like [email protected] to have their e-mail verified if they are having trouble getting the verification e-mail. I have a website with PHP/MySQL that I'd like to implement this same functionality, but I haven't done much with e-mail besides sending it so I don't even know where to start to set something like this up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,如果您的邮箱是 IMAP,您可以通过 PHP http:// www.php.net/manual/en/ref.imap.php(如果启用,请检查您的 phpinfo())并阅读该特定邮箱 (http://www.php.net/manual/en/function.imap-open.php)。
也许每 10 分钟运行一次 cronjob(我说 10 分钟,因为我没有看到很多人这样做),循环遍历所有电子邮件(如果有的话),运行您的逻辑来验证该电子邮件帐户,向他们发送一封电子邮件以表明其已验证,然后从您的帐户中删除该电子邮件项目,这样您就不会造成大量积压的电子邮件。
希望有人验证的方式很冒险,但这可能是这样做的一种方法。
Basically if your mailbox is an IMAP you could reference these functions via PHP http://www.php.net/manual/en/ref.imap.php (if enabled, check your phpinfo()) and read that specific mailbox (http://www.php.net/manual/en/function.imap-open.php).
Run a cronjob every 10 minutes maybe (I say 10minutes as I dont see many people doing this), loop thru all the emails (if any), run your logic to verify that email account, send them an email to say its been verified, then delete that email item from your account so you are not creating a massive backlog of emails.
Its risky way of wanting someone to verify but this is probably one way of doing it.
如果您的主机允许,您可以将收到的电子邮件传送到程序< /a> (在您的例子中,是一个 PHP 脚本),然后它可以解析消息并决定要做什么。
但是,我同意这不是很安全。除非您实施 DomainKey 检查或 DNS 查找,否则很容易欺骗发件人。
If your host allows you to, you can pipe received email to a program (in your case, a PHP script), which could then parse the message and decide what to do.
However, I agree that this isn't very secure. It would be very easy to spoof the sender, unless you implement DomainKey checking or DNS lookups.