如何使用ASP.NET检查电子邮件地址是否存在?

时间:2012-10-03 11:22:35

标签: asp.net c#-4.0

如何使用ASP.NET检查给定的电子邮件(任何有效的电子邮件)地址是否存在?

5 个答案:

答案 0 :(得分:1)

you send invitation mail to user with encrypted key..
If user is verified you have to verified key and you have only verified email..

答案 1 :(得分:1)

如果没有实际发送邮件,您无法检查电子邮件是否存在。

您唯一可以检查的是地址是否与正则表达式一致:

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");

答案 2 :(得分:0)

这是一个可能适合您的代码解决方案。此示例发送的消息来自与消息中指定的From:address不同的地址。这在处理退回邮件并且开发人员想要将退回邮件重定向到另一个地址时非常有用。

http://www.afterlogic.com/mailbee-net/docs/MailBee.SmtpMail.Smtp.Send_overload_3.html

答案 3 :(得分:0)

整个过程并非如此简单。 它需要与电子邮件服务器进行完整的通信,并询问他是否存在此电子邮件。

我认识的供应商提供了一个dll来进行所有这些通信,并检查服务器上是否存在电子邮件,http://www.advancedintellect.com/product.aspx?mx上的aspNetMX

答案 4 :(得分:0)

首先,您需要导入此命名空间:

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完整源代码。