Not long time ago I had the following problem: I needed to send a mail but didn't have mail (a small client program for sending mail in the console installed) so I would have had to install the mailx package or find another solution. I decided for the second because I weren't sure if it is ok to install mailx (I'm not the only admin). Finally I discovered that we have netcat installed so I made a few tests and connected to the localhost 25 witch success.

I received the mail and everything went find so far.

Here is the magic, type:

nc localhost 25

And afterwards: (not the ^M is CR <carrier return> which is needed, so don't omit it!)

From: Joachim Schiele <> ^M
To: Joachim Schiele <> ^M
Date: Wed, 14 Dec 2005 23:12:27 +0100 (CET) ^M
Subject: Domain News^M
Domain is up?^M

Afterwards I created a script from it and saved the mail contenet [1].

Afterwards you can call it like this [from a bash script]:

nc localhost 25 < /home/joachim/mail

Of course this is a very static use but you are free to do whatever you like.

Powered by MediaWiki