5

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' [email protected] ???

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

2
  • mail does not use SMTP. It just calls /usr/bin/sendmail, which takes care of delivery. Feb 12, 2010 at 13:12
  • You can add sendmail parameters to it though via -f, can't you?
    – Mark L
    Feb 12, 2010 at 13:15

1 Answer 1

5

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

2
  • Looks like you beat me...I like your page better, anyway.
    – Paul Kroon
    Feb 12, 2010 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, 2010 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .