Building network automation solutions

9 module online course

Start now!

Simple SMTP server

When I was testing the SMTP client on the routers (configured with action … mail command or as part of EEM SMTP library), I didn't want the messages with weird addresses and content to circulate through our e-mail system (plus I wanted to see the results immediately), so I wrote a simple SMTP server in Perl that prints the messages it receives. It accepts a single parameter: the IP address to listen on (only needed on workstations with multiple IP addresses).

You need the Net::SMTP::Server module on top of the standard Perl distribution to make it work.

You can download the PERL source code or compiled EXE file (for Windows users) from CT3 wiki.


  1. Why not simply listen on (any) IP address instead of resolving hostname to IP address of one interface?
  2. Right. Maybe because the router also has external-facing interfaces, and Ivan doesn't want to become a free relay for SPAM ? :)

    Listening on is asking for trouble. bind to if no need to accept outside connections. bind to specific interfaces otherwise. But try to avoid ;)

    ""be conservative in what you generate, and liberal in what you accept.""

    Going back to the SMTP "basic server" - I've had good results using the Mercury Mail MTA - since 1999, my "ligthweight mail server of choice for lab-related stuff" -
  3. Great bluedaemon. But this is lab - the server would be running on workstation/laptop, not on a router. The server is only capable to dump incoming mail on standard output, not to store or relay them.
  4. My sample session

    220 MacGyver SMTP Ready.
    helo localhost
    250 You're polite.
    mail from: <>
    250 it.
    rcpt to: <>
    250 it.
    354 Give it to me, big daddy.
    From: <>
    To: <>
    Subject: aaa

    250 I got it darlin'.
    221 Good.

    give me odd result

    Waiting for incoming SMTP connections on localhost
    Incoming mail ...received
    From: <>
    To: ARRAY(0xb6eb90)

    From: <>
    To: <>
    Subject: aaa


    The question is: what is ARRAY(0xb6eb90) ?
  5. @anonymous(1): You can always run it with You can also change the default behavior by replacing hostname with "" in line 6 of the code.

    @bluedemon: Thanks for the Mercury Mail MTA tip. Exactly what I've been looking for during the last few months.

    @anonymous(4): Thanks for the bug report, I've fixed the code.
  6. Zip file from your site still contains buggy version. The compiled version is very handy for me. Please fix it.
  7. @Anonymous(5): Uploaded the fixed code in zip file.

    ... and why don't you guys choose some unique identifier (just select "Other" in the identity field and type in whatever you feel like), this "anonymous(N+1)" stuff is getting tedious :(
  8. This version works pretty well. Thank you.
Add comment