This is a quick tips to simulate a fake mailserver useful if you want to test and application which send emails.

You need netcat (nc) software installed and no email server active on the port 25.

In order to open the privilege port 25 I use the root user. The dialog is separated in two part:

This is what you type in the nc command line starting with a 3
digits number.

and this is what is suppose to come from your email application, without the >> heading.

>> application answer

First run the nc command listening to localhost on port 25 with

nc -l -p 25

then start the client application and once is connected (you do not see it):

220 smtp.localhost.local MyFake SMTP MAIL Service
>> EHLO localhost

250 smtp.localhost.local HiThere
>> MAIL FROM:<myuser@mydomain.com>

250 2.1.0 OK
>> RCPT TO:<destination@yourdomain.com>

250 2.1.5 OK
>> DATA

354 Start mail input; end with <CRLF>.<CRLF>
>> content of the email you want to see and check terminated by
>> a single line with a dot.
>> .

250 2.0.0 Ok: queued as ForGetIt
>> QUIT

221 2.0.0 Bye

Now on the other side let's simulate the email client instead using the telnet command. Plenty of example can be found in internet on this.

Note that this time the >> is what the server send. Start with the command (no need to be root this time)

telnet localhost 25
>> 220 smtp.localhost.local MyFake SMTP MAIL Service

EHLO localhost
>> 250 smtp.localhost.local HiThere

MAIL FROM:<myuser@mydomain.com>
>> 250 2.1.0 OK

RCPT TO:<destination@yourdomain.com>
>> 250 2.1.5 OK

DATA
>> 354 Start mail input; end with <CRLF>.<CRLF>

content of the email you want to see and check terminated by a single line with a dot.
.
>> 250 2.0.0 Ok: queued as ForGetIt

QUIT
>> 221 2.0.0 Bye

-> Send a comment: Unless requested otherwise I may add it, or some extract, to this page.