简体   繁体   English

如何验证email地址是否存在?

[英]How to verify if a email address exists?

Is there any possible way to find out if an email address exists in c#?有什么办法可以查出email地址是否存在于c#中?

eg I have an email address like abcded@yahoo.com or asdf234@hotmail.com How can I do the validation?例如,我有一个 email 地址,例如 abcded@yahoo.com 或 asdf234@hotmail.com 我该如何进行验证?

Once upon a time the Internet and the SMTP mail transfer protocol was invented. 曾几何时发明了Internet和SMTP邮件传输协议。 It was back in the good old days when everyone were nice and friendly, so a command was included in the SMTP protocol to verify email addresses - the VRFY command. 它回到了过去,当时每个人都很友好,所以SMTP协议中包含一个命令来验证电子邮件地址 - VRFY命令。

However, darkness came upon the Internet and brought spammers, worms and other evil, so the sysadmins of the Internet mail servers defended what was good by disabling the VRFY command. 然而,互联网上出现了黑暗,并带来了垃圾邮件发送者,蠕虫和其他邪恶的东西,因此互联网邮件服务器的系统管理员通过禁用VRFY命令来保护好的东西。

So the short answer is: No. 所以简短的回答是:不。

最明显的方法是向邮件地址发送电子邮件,并要求收件人回复或单击链接。

Basicly: you can't. 基本上:你做不到。 There are servers that support finger (to verify that a particular user exists), but for Hotmail/Gmail it's just not possible. 有些服务器支持finger(以验证特定用户是否存在),但对于Hotmail / Gmail,这是不可能的。 The mail will bounce though. 邮件虽然会反弹。

In general that's not possible. 一般来说,这是不可能的。 Which is why many websites have that to sign up you have to give your email address and they'll send a link where you have to go to that link to confirm that it's your email. 这就是为什么很多网站都有注册你必须提供你的电子邮件地址,他们会发送一个链接,你必须去那个链接,以确认这是你的电子邮件。

No way at all 完全没办法

If it's for a reason, such as signing up with verification, then someone will reply when you send. 如果出于某种原因,例如注册验证,则有人会在您发送时回复。

Why do you want to do this? 你为什么要这样做?

I'm a little bit late, but this might help someone Now you can check if the email exists or not.我有点晚了,但这可能对某人有所帮助现在您可以检查 email 是否存在。

Here is the code that I'm currently using on my website.这是我目前在我的网站上使用的代码。 You can use the same API in c#您可以在 c# 中使用相同的 API

    if(isEmialExist("EMAIL_ADDRESS_THAT"))
{
    echo "email exists, real email";
}
else
{
    echo "email doesn't exist";
}


function isEmialExist($emailAddress)
{
    if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
     return false; //invalid format
    }
    //now check if email really exist
    $postdata = http_build_query(array('api_key' => 'YOUR_API_KEY', 'email' => $emailAddress ));
    $url = "https://email-validator.com/api/v1.0/json";
    $opts = array('http' => array( 'method'  => 'POST', 'header'  => 'Content-Type: application/x-www-form-urlencoded', 'content' => $postdata ));
    
    $context  = stream_context_create($opts);
    $result = file_get_contents($url, false, $context);
    $data = json_decode($result, false);
    return $data->is_exists;
}

You can find more details here.您可以在此处找到更多详细信息。 https://email-validator.com/tutorial https://email-validator.com/tutorial

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

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