- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
编辑:我的网站仅向 Gmail 和 Google Apps 用户提供服务,并且希望确保其他免费电子邮件用户在启动 oauth 配对时不会收到错误消息。
事情是这样的:要么我试图弄清楚这是一个 Gmail/Google Apps 地址,要么试图阻止流行的免费邮件用户尝试订阅。
我想阻止所有属于 Gmail、Hotmail、Yahoo 等的“免费”电子邮件地址在我的网站上订阅。
我怎样才能在 javascript 中正确地做到这一点?这是我开发的第一个脚本:
var domain_matche = /@(.*)$/.exec(email);
var domain_name = domain_matche[1].substring(0, domain_matche[1].indexOf(".", 0))
if (domain_name == "hotmail" || domain_name == "yahoo" ) {
alert("not a valid email");
}
但它不会检测像 test@hotmail.co.il 或 test@subdomain.hotmail.com 这样的电子邮件。
你能帮忙吗?非常感谢!
最佳答案
首先,我建议不要这样做。由于雅虎确实提供高级付费服务(我自己正在使用该服务,如果您不允许我注册,我会很生气)。
此外,您还需要同时在客户端 (JS) 和服务器上实现(PHP、ASP.net 或您正在使用的任何工具),因为我可以轻松禁用 Javascript,并且您的检查不会然后执行。
但是,如果您知道自己在做什么并希望正确完成,请先查找“@”,然后查找以下“.”。并获取它们之间的字符串。
代码:
// get index of '@'
var index_at = email.indexOf('@');
// get index of the '.' following the '@' and use it to get the real domain name
var domain = email.substring(index_at + 1, email.indexOf('.', idx));
// now use the domain to filter the mail providers you do not like
检查所有子域的代码(对于 abc@subdomain.hotmail.com):
// get the string after '@'
var after_at = email.substring(email.indexOf('@') + 1);
// get all parts split on '.', so for abc@x.y.z you can check both x and y
var dot_split = after_at.split('.');
for(var i = 0; i < dot_split.length; i++)
// check each dot_split[i] here for forbidden domains
关于javascript - 检查电子邮件地址是否不是 "free webmail"(hotmail、yahoo...),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8271578/
WebMail.SmtpServer = SmtpServer; WebMail.UserName = SmtpUsername; We
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我可以使用 JavaMailAPI 向多个 ID 发送邮件。 添加了“收件人”地址,例如; message.addRecipients(Message.RecipientType.TO,Interne
有没有办法实现 mailto: 与网络邮件客户端一起使用的链接? 编辑 - 所以传统的 mailto 链接(正如我所怀疑的那样)不起作用。那么有没有人看到过与您在各种最受欢迎的网站上看到的那些 R
我需要在我的 Java 网络应用程序中提供电子邮件发送和接收功能。将其视为提供嵌入在应用程序中的轻量级 IMAP 客户端。 是否有提供类似功能的基于 Java 的开源库/项目/网络邮件解决方案? 请注
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我有一个发送电子邮件的java代码。当我们在网络邮件上打开同一封电子邮件时,字体保持不变,但当我在 Outlook 中打开该电子邮件时,字体会发生变化。我无法弄清楚为什么会发生这种情况?相同的代码在不
我想用在各种网络邮件界面中常见的行为来实现文件上传。我的意思是,附件(一个或多个)由打开的文件对话框选择,然后它们的名称出现在(例如)带有消息正文的文本区域下。并且只有添加附件的信息,并在提交表单时上
我将我的 Apache HTTP 服务器设置为将所有请求转发到 Tomcat,即 proxy_ajp.conf 如下所示: ProxyPass / ajp://localhost:8009/ Tomc
我是一名相对较新的 Web 开发人员,正在寻找一个足够丰富的业余爱好项目,以实际学习一些 PHP 和其他与 Web 相关的东西。 我正在考虑一个简单的小型网络邮件客户端,但不确定从哪里开始。 我确定我
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
在关于 System.Web.Helpers.Webmail.Send 之前,我们已经在 StackOverflow 上看到了一些类似的问题,但我没有看到对发生的事情的正确解释。 关于 to: 参数,
我会将 nodemailer 连接到 Aruba Webmail。这个我试过了 var smtpTransport = nodemailer.createTransport({ host: "sm
我正在处理 html 电子邮件。我在 table 上显示 2 张图片时遇到问题:
我知道 background-image 在 windows outlook 中是不允许的,你可以在下面检查它: background-image: url(image); CSS Support G
编辑:我的网站仅向 Gmail 和 Google Apps 用户提供服务,并且希望确保其他免费电子邮件用户在启动 oauth 配对时不会收到错误消息。 事情是这样的:要么我试图弄清楚这是一个 Gmai
我想创建一个 java 程序来连接到 Outlook 网络邮件服务器以检查未读电子邮件。我不是在寻找基于开源 Java 的电子邮件客户端等。等等。 我基本上是在问是否可以为 Outlook Webma
我目前有一个邮件服务器正在运行。我可以通过 mywebsite.com/roundcube/登录我的网络邮件客户端 网络邮件使我能够正确地发送和接收电子邮件。日志显示所有进出的邮件,一切正常。我已经从
我有一个虚拟服务器,但它没有 ssl 证书。当我尝试使用来自 http://webmail.oznurdavetiye.com 的网络邮件时,由于 https 重定向,我遇到“您的连接不安全消息”。
这个问题在这里已经有了答案: PHP mail function doesn't complete sending of e-mail (31 个答案) 关闭 7 年前。 我正在使用 000webh
我是一名优秀的程序员,十分优秀!