Programatically finding SMTP Server on local network

G

Gancy

Is there a way to programatically find a SMTP server available on the
network? I am writing a C#.Net program, which should first find a SMTP
server on LAN and use that SMTP server to send an email.

Thanks
Ganesh
 
V

Vadym Stetsyak

Hello, Gancy!

G> Is there a way to programatically find a SMTP server available on the
G> network? I am writing a C#.Net program, which should first find a SMTP
G> server on LAN and use that SMTP server to send an email.

This is rather straightforward approach but... SMTP port is 25, then you can try to connect to every host on your network on port 25 if connection is successful then SMTP server will be found...

Another question is how can you find all the host in the local network?
The answer is use NetServerEnum API, take a look at
( http://www.codeproject.com/csharp/networkshares.asp )
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
W

Willy Denoyette [MVP]

Don't know why you ever need this for. It's up to the network folks to
publish this information, or in a DNS or in a Directory Server like the
Windows AD or at least on paper, Relying on port numbers isn't the right
thing to do, are you going to send your mails to a server just because he
listens on port 25?

Willy.

| Is there a way to programatically find a SMTP server available on the
| network? I am writing a C#.Net program, which should first find a SMTP
| server on LAN and use that SMTP server to send an email.
|
| Thanks
| Ganesh
|
 
G

Gancy

I have developed a program, which could be carried in a USB memroy
stick and run on any PC, it would collect some status various status
information and generate XML file of those status and send that as an
attachment to a pre-known email id. sounds strange but thats the
requirement anyway. Given this context application must automatically
find a SMTP server, if any, on the LAN. Even if i find a method to
figure out SMTP server, i might need an authentication to send email
through that STMP server outside of the network. Anyway thats a
different issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top