开发者

How to retrieve/negotiate the supported Security Methods and Authentication Methods of a SMTP-Server

I am using C# (.NET 4.0) and the System.Net.Mail.SmtpClient Class in order to send an EMail to a SMTP-Server. For now i'm able to actual send an EMail to the SMTP-Server and see it immediatly in my Inbox-Folder of Thunder开发者_JS百科bird.

This Test was without specifiying any Authentication Methods nor Security Methods. But usually SMTP-Server requires some kind of Authentication, i assume.

I wonder, whether it is possible to ask the SMTP-Server, what Authentication Methods it supports and afterwards negotiate to use the desired one. I'm thinking of something like asking the SMTP-Server about the supported Authentication Methods and get back a list of e.g.:

  • No Authentication
  • Password, plaintext
  • Password, crypted
  • Kerberos
  • NTLM

Accordingly for the Security Methode of the Connection:

  • No Security on the Connection
  • STARTTLS
  • SSL/TLS

Is there a Way to programmatically retrieve the supported Methods from a SMTP-Server?


It is possible, but not through the .NET class; rather, you'll need to use a socket-level connection to send the appropriate EHLO request to the server and then parse the response.

Details on the socket programming you'll need are here: How to validate SMTP server

You'll want to parse the response from the server. The Wikipedia entry on SMTP AUTH has a useful sample dialog: http://en.wikipedia.org/wiki/SMTP_Authentication

Utilities like Wireshark (http://www.wireshark.org/) can be handy debugging this kind of work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜