Verifying an email address exist in C#

2020-02-26 01:08发布

Regarding this post about email verification,

using C#, how would you

  1. issue a VRFY command
  2. issue a RCPT command

6条回答
做自己的国王
2楼-- · 2020-02-26 01:56

There's a nice project here with code snippets on how to achieve this, but as Spence mentioned they may not always work correctly.

查看更多
▲ chillily
3楼-- · 2020-02-26 02:02

Normally.

  • VRFY: Forget it. Seriously ;) No server will answer - no sane one. Was used too much by spammers.

    • For the rest: connect to server using TCP, "just do it" (i.e. program the SMTP handshake, then go on).
查看更多
Rolldiameter
4楼-- · 2020-02-26 02:03

If you're not worried about public SMTP servers lying to you (take a look at section 2.11 here: http://tools.ietf.org/html/rfc2505), then the best way might actually be to open up a TcpClient to the server and run the SMTP protocol yourself. SMTP is a really, really easy protocol. You can pretty much learn everything you need to know from Wikipedia: http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol

查看更多
成全新的幸福
5楼-- · 2020-02-26 02:04

I think you will find that in many instances these functions will intentionally lie to you to defeat spammers. If there were a way to confirm an email is real other than having a user click on a validation (or unsubscribe....) link then spammers would be very happy people.

Just to be clear, the best way to verify an email address is to send a user an email containing a link, and wait for them to click on the link to verify they received the email. Any other technique (with the exception of a corporate/intranet environment) should fail and/or lie to defeat spammers.

查看更多
男人必须洒脱
6楼-- · 2020-02-26 02:12

IMO, RCPT method is the best one, and I still use it everyday.

Here are the necessary code : http://mailsystem.codeplex.com/SourceControl/changeset/view/51422#541825

The class is quite heavy, you will have to pick the code snippet you need from the source code.

查看更多
Bombasti
7楼-- · 2020-02-26 02:13

You could try using something similar to this:

http://www.vcskicks.com/download-file-ftp.php

Instead of using Ftp, use SMTP.

查看更多
登录 后发表回答