简体   繁体   English

filter_var W / FILTER_VALIDATE_EMAIL与自定义REGEX

[英]filter_var W/ FILTER_VALIDATE_EMAIL vs custom REGEX

I've searched this site for similar answers and I still can't make up my mind. 我已经在该网站上搜索了类似的答案,但仍然下定决心。 Also I'm new to this site. 我也是这个网站的新手。

I'm in the process of developing a PHP script to allow users to register. 我正在开发一个PHP脚本以允许用户注册。 After they register they are sent a email with a token to validate that they have access to that email saying it is valid and it will mark them as 'valid users' otherwise it will delete that entry after a set time. 在他们注册后,将向他们发送一封带有令牌的电子邮件,以验证他们是否有权访问该电子邮件,并声明它们是有效用户,并将其标记为“有效用户”,否则将在设置的时间后删除该条目。 What I'm wondering is if a custom REGEX that I made (which works fairly good for the most part just needs tuning every now and then) or if filter_var with FILTER_VALIDATE_EMAIL is better than my custom REGEX. 我想知道的是,我制作的自定义REGEX(在大多数情况下效果相当好,只是偶尔需要调整),或者带有FILTER_VALIDATE_EMAIL的filter_var是否比我的自定义REGEX好。 I know that if you send too many emails that bounce back you might be marked as a spammer site and my client wouldn't like that too much. 我知道,如果您发送过多的电子邮件反弹,那么您可能会被标记为垃圾邮件发送者网站,而我的客户不会非常喜欢。

Anything else that might help would be great help to me. 其他可能对我有很大帮助的东西。

I would use Filter_validte_email if you don't have a lot of experience validating email or writing regex. 如果您没有太多验证电子邮件或编写正则表达式的经验,我将使用Filter_validte_email。 It is also important to remember that any regex or filter will not prevent emails that bounce back, they will only check to make sure the entered address looks like it should. 同样重要的是要记住,任何正则表达式或过滤器都不会阻止电子邮件反弹,它们只会检查以确保输入的地址看起来应该正确。 Thus you will get a valid check on noaddress@nodomain.tld even though this clearly will not be delivered unless nodomain.tld happens to exist and there happens to be a user noaddress with a mail account there. 因此,您将获得对noaddress@nodomain.tld的有效支票,即使除非nodomain.tld恰好存在并且那里的用户noaddress带有邮件帐户,否则显然不会发送该支票。

See How to check if an email address exists without sending an email? 请参阅如何在不发送电子邮件的情况下检查电子邮件地址是否存在?

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

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