【问题标题】:How to check email address exists or not using ASP.NET?如何使用 ASP.NET 检查电子邮件地址是否存在?
【发布时间】:2012-10-03 11:22:35
【问题描述】:

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

【问题讨论】:

标签: asp.net c#-4.0


【解决方案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");

【讨论】:

  • 这只是检查有效的电子邮件 FORMAT !!!。每封具有正确格式的电子邮件都可能不存在
【解决方案2】:
you send invitation mail to user with encrypted key..
If user is verified you have to verified key and you have only verified email..

【讨论】:

    【解决方案3】:

    这是一个可能适合您的代码解决方案。此示例从不同于 From: 消息中指定的地址的地址发送消息。当应处理退回的消息并且开发人员希望将退回的消息重定向到另一个地址时,这很有用。

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

    【讨论】:

      【解决方案4】:

      整个过程并不是那么简单。 它需要与电子邮件服务器进行全面通信,并询问他是否存在此电子邮件。

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

      【讨论】:

        【解决方案5】:

        首先你需要导入这个命名空间:

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

        【讨论】:

          猜你喜欢
          • 2016-08-20
          • 2012-09-09
          • 2016-04-06
          • 2011-08-30
          • 2011-08-17
          • 2016-04-05
          • 2016-02-21
          • 2016-08-20
          • 1970-01-01
          相关资源
          最近更新 更多