Linux – Mail command using alternative SMTP port

emaillinuxsmtp

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

Best 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

Related Topic