Home > Perl > How to test SMTP Connection

How to test SMTP Connection

GD Star Rating
loading...

SMTP 150x150 How to test SMTP Connection Hello all and happy new year! Even if I should be on holiday I'm working from home, and while I'm waiting for me colleague to call me back from the office I've thought to post this sharing something I use often.

In my work I often deal with Mail servers, which were and still are my field of specialization, and one of the most basic tasks I deal with when installing new servers is checking SMTP daemon (or service) is working properly, as you know this is pretty easy to accomplish opening a telnet connection to the server we want to test and writing the verbs needed to the SMTP daemon. This is pretty easy and standard but I'm a lazy person and this morning while testing a new server I've written this little and dirty script to do the job for me ;)

Here we go :

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
( echo HELO ccielogs.com
sleep 2
echo MAIL FROM:<test@somedomain.com>
sleep 2
echo RCPT TO:<test@someotherdomain.com>
sleep 2
echo DATA
sleep 2
echo Subject:Test-Mail!
sleep 2
echo If you can read this, it Works!!!
sleep 2
echo .
sleep 2
echo QUIT
) | telnet XXX.XXX.XXX.XXX  25

To make this work all you have to do is to modify the Mail From and Rcpt to fields so that valid sender and recipients are listed (this is not strictly necessary but would help being able to read the test mail just to be extra sure), last modification needed is of course the IP address of the server to test.

Once copied all you have to do is to save the file as smtp.sh (or whatever name you like) and make it executable or launch it with sh smtp.sh.

For your convenience I've also attached the script at the end of the post with a TXT extension so that you can rename and use it in your environment.

If you you found this useful or informative please take some time to digg and share the article!

Lethe.

dp seal trans 16x16 How to test SMTP Connection  Copyright secured by Digiprove © 2010

GD Star Rating
loading...
GD Star Rating
loading...
Related Posts with Thumbnails
Print
Categories: Perl
  1. Skull
    January 5th, 2010 at 13:57 | #1

    Hai un po' di scazzi con l'URL-encoding all'interno della box ;-)

    GD Star Rating
    loading...
    GD Star Rating
    loading...
  2. January 7th, 2010 at 06:32 | #2

    Dove dove? Dimmi che sistemo subito, finite le ferie mi posso ridedicare un pò al blog, ero completamente sparito :D

    GD Star Rating
    loading...
    GD Star Rating
    loading...
  1. January 2nd, 2010 at 12:52 | #1
CommentLuv Enabled

 

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
This site is protected by WP-CopyRightPro