Search Forum
(53671 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


 
Printable Version

DNS Client Utility
By Jaimon Mathew

DNS Client utility This is a cut down version of the DNS client, which can be used to retrieve the MX (mail exchange) record for any Internet address from a DNS server. You can use this MX record to send e-mails directly without the need for any mail server as a host. The library can be compiled to a DLL file. One test program is also given to show all the mail exchanger records for any particular address. More information on DNS can be found from these RFCs. Rfc1034(http://www.ietf.org/rfc/rfc1034.txt) and rfc1035(http://www.ietf.org/rfc/rfc1035.txt). Once you got the MX record, you can directly opens its SMTP port, and can issue the SMTP commands. You may get more than one record for some sites. In that case do a sorting based on the preference. The lowest value is the most preferred address. (With a small change it can work on Beta 1 also)

Source code for DnsLite.cs

Source code for test.cs

The compile strings for both .cs files is included in the .cs files.

Here is a sample session, which is sending mail to a hotmail account directly.

1)  Test hotmail.com
    This will return all the MX records for hotmail.com
2)  Do telnet to one of the address got from the program (to port 25)
    telnet mc1.law5.hotmail.com 25
3)  Issue the following SMTP commands.

    HELO jaimonmathew
    MAIL FROM: god@heaven.org
    RCPT TO: jaimonmathew@hotmail.com
    DATA
    From: god@heaven.org
    Subject: Just another message from God
    
    First Line
    Second ....
    
    Last Line
    .
    QUIT