【发布时间】:2012-10-03 11:22:35
【问题描述】:
如何使用 ASP.NET 检查给定的电子邮件(任何有效的电子邮件)地址是否存在?
【问题讨论】:
-
你说的是语法还是它是否真的存在?在后一种情况下,您不能;它只会反弹。在这里检查类似的问题:stackoverflow.com/questions/7246341/…
-
您认为电子邮件地址“存在”意味着什么?
如何使用 ASP.NET 检查给定的电子邮件(任何有效的电子邮件)地址是否存在?
【问题讨论】:
如果不实际发送邮件,则无法检查电子邮件是否存在。
您唯一可以检查的是地址是否使用正则表达式的格式正确:
string email = txtemail.Text;
Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
Match match = regex.Match(email);
if (match.Success)
Response.Write(email + " is corrct");
else
Response.Write(email + " is incorrct");
【讨论】:
you send invitation mail to user with encrypted key..
If user is verified you have to verified key and you have only verified email..
【讨论】:
这是一个可能适合您的代码解决方案。此示例从不同于 From: 消息中指定的地址的地址发送消息。当应处理退回的消息并且开发人员希望将退回的消息重定向到另一个地址时,这很有用。
http://www.afterlogic.com/mailbee-net/docs/MailBee.SmtpMail.Smtp.Send_overload_3.html
【讨论】:
整个过程并不是那么简单。 它需要与电子邮件服务器进行全面通信,并询问他是否存在此电子邮件。
我知道一个供应商提供了一个 dll 来进行所有这些通信并检查服务器上是否存在电子邮件,http://www.advancedintellect.com/product.aspx?mx 的 aspNetMX
【讨论】:
首先你需要导入这个命名空间:
using System.Text.RegularExpressions;
private bool ValidateEmail(string email)
{
Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
Match match = regex.Match(email);
if (match.Success)
return true;
else
return false;
}
Visit Here 到完整的源代码。
【讨论】: