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' myemail@address.com ???

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,
Mark

link|improve this question

60% accept rate
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
feedback

1 Answer

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:

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

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

link|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
feedback

Your Answer

 
or
required, but never shown

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