Verifying an email address exist in C#

こ雲淡風輕ζ 提交于 2019-12-18 12:33:00

问题


Regarding this post about email verification,

using C#, how would you

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

回答1:


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.




回答2:


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.




回答3:


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




回答4:


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:


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).



回答6:


You could try using something similar to this:

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

Instead of using Ftp, use SMTP.



来源:https://stackoverflow.com/questions/3045861/verifying-an-email-address-exist-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!