Testing a mail server

daviddoria

Member
Joined
Jan 11, 2007
Messages
13
Programming Experience
Beginner
I often get calls from a friend of mine's company saying "ahhh our email is not working!". I thought I could write a program that would test a few things that they could run and have easy answers to my questions when they call. Things like "Is your internet connection alive?", "can you send mail but not receive it?", etc.

Testing the outgoing mail seems easy:

VB.NET:
        Try
            Dim EmailFrom As String = "test@from.com"
            Dim EmailTo As String = "test@to.com"
            Dim EmailSubject As String = "Test"

            'compile report
            Dim EmailBody As String = "test"

            Dim email As New Net.Mail.MailMessage(EmailFrom, EmailTo, EmailSubject, EmailBody)

            Dim emailClient As New Net.Mail.SmtpClient("smtp.server.com", 587)
            emailClient.EnableSsl = True
            emailClient.Credentials = New Net.NetworkCredential("test@from.com", "passwd")

            emailClient.Send(email)


        Catch ex As Exception
            MessageBox.Show("uh oh, error!")
            End
        End Try

        MsgBox("Email sent.")

But how would I test their incoming pop mail server? Is there a way to analyze the results of a telnet?

This command:
VB.NET:
telnet mail.server.com 110

returns
VB.NET:
OK POP3 READY

when the server is alive.

Or is there a way to actually receive the test email that was just sent?

Any thoughts on this? Also, any other comments on things that could be tested for network/mail "up" analysis are welcome!

Thanks,

Dave
 
Hello.

You could write your own POP3 communication class...also you should have a look at the POP3 protocol, f.e. on Wikipedia ([ame=http://en.wikipedia.org/wiki/Pop3]Post Office Protocol - Wikipedia, the free encyclopedia[/ame]). Of course it's even possible to receive mails with telnet, a default POP3 session looks pretty similar to this:
VB.NET:
>>> +OK Ready
<<< USER myUserName
>>> +OK User set
<<< PASS swordfish
>>> +OK You're logged in
<<< STAT
>>> +OK 12 69953
<<< RETR 4
>>> +OK EMail follows:
<here is your mail body>
>>> QUITE
<<< +OK Have a nice day

While <<< is outgoing (you send that) and >>> is incoming from the server.

Bobby
 
Back
Top