Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have setup an SMTP server on port 10025. I wanted to test sending emails to it via the command line.

Is there a parameter I can give the mail command to use the smtp server on 10025?

echo hello | mail -s'testing' ???

I do have a seperate smtp server running on port 25 as well but I don't want to be communicating with that one or switch it off.

Thanks for you time,

share|improve this question
mail does not use SMTP. It just calls /usr/bin/sendmail, which takes care of delivery. – grawity Feb 12 '10 at 13:12
You can add sendmail parameters to it though via -f, can't you? – Mark L Feb 12 '10 at 13:15
up vote 3 down vote accepted

For testing, just telnet to the port: cf. this sample SMTP.

Postscript If you want a one-liner, put the following with the requisite arguments in your path:

from=$1; to=$2
echo EHLO $from
echo MAIL FROM: $from
echo RCPT TO: $to
echo DATA
echo Subject: Test $from $to
echo Test message body.
echo .

And then pipe that script, with its two arguments, into telnet localhost 10025

share|improve this answer
Looks like you beat me...I like your page better, anyway. – Paul Kroon Feb 12 '10 at 12:03
It just seems a shame that I couldn't have a 1-line command sitting in a bash script. Do you know of any other command-line smtp tools for sending? I've resorted to a PHP script for the moment :( – Mark L Feb 12 '10 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.