specifying smtp relay on commandline of mail cmd

Hi all,

On my opensuse 11.4 box (although I assume the version is irrelevant), I’m trying to figure out how to do something with the mail command. We have multiple smtp relay servers and sometimes I have to test to verify that mail is bouncing off of them successfully. On my laptop, in my main.cf file for postfix, I’ve got the relay server listed. But to test multiple servers, I have to change the main.cf, restart postfix, send message, and then repeat for each test.

I’m trying to figure out a way to specify the smtp relay on the command line. I’ve been playing with the -S option which is supposed to allow variables and one of the variables in the man page is ‘smtp’. I’ve tried several different syntaxes but nothing seems to work.

The closest I’ve come is:
mail -S smtp 10.1.0.63 -s “test” user@email.com < main.cf

That syntax doesn’t give me an error but it still routes the message off the smtp server listed in main.cf which is not 10.1.0.63.

Anybody know how to accomplish this?

thanks

Works for me, or at least tries to contact the non-existent server I specified:

$ mail -S smtp=foo.bar -s hello me < /etc/issue
Could not resolve host: foo.bar
"/home/me/dead.letter" 13/317
. . . message not sent.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The important difference being you put in the ‘=value’ portion as
specified in the manpage. :slight_smile:

Good luck.


Want to yell at me in person?
Come to BrainShare 2011 in October: http://tinyurl.com/brainshare2011
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOQcaaAAoJEF+XTK08PnB53EsP/RTn/k+AjoRoaOCqq41uDWcD
JjVfjQkQ/Hc7tzxk2+XldVKXFIUu+JDTyKjVy/e08w2Inn6sWCARakeYHjXJh7lj
QqAhYmq89xmBfdjDH9PFZ8oEqfhYHoaxd1ABL4danTF5dZXSr7vgyOoi9Cpn798D
pOZUiCveQidpTqqsjpuB8ySXlKbJ6hryMK4HaixuxZadfwSFGzaIiYVl0rWR5YA6
41YVHVzotRjH0+ufxhFRgSK+HIIPZMs+Pktm4d4c2hgj20DCQgrJeIRiabqMB0Jo
R9gyiuO79oUVTbxht5nbPe9LjWtRXtoRH/CwVzbJT6RwHpV8mDcmJgEbj54jzeaf
4YU531CkicUIcKIj9TCf48NB+76aVaRH7aMaZuK9PbuM2zuVT3utblG7Z/eiOZ27
u6/9Q8pNAQB3aPWrXUqK2aPc4lFposJ3YQgvN6Hiohe7PxkjsyDcqsBYvQWrqIGW
JD7WLFpVKweqeYzqb3i/ONNr9Evm7UFBv1HgYIvrgwNSA4FalTyRCxquQs9FcDYJ
cWZztyFx4S2iZbFiXRw3bX55HANnVNi9Rn3roPpKr/q5BbEku+MslMxBIH7EJFxe
jqDugH2wIzN3Hk/OnWbCiOzHoYrsgkjuWO91UERy5PaY3kFjbAas2ik4Q7IjbE3c
ak4x30d7sX8m9ZGABqF8
=5gwJ
-----END PGP SIGNATURE-----

That darn “=” sign will get you every time. It was too obvious! That was it.

mail -S smtp=serverIP -s “test from smtp #1myemail@domain.com

So I can take this and put multiple mail commands in a short script to test mail routing from all our smtp servers with a single command.

Thanks for the second set of eyes!

It should be pointed out that if you’re having problems with this working on any distro, make sure you have the heirloom-mailx implementation installed, not the GNU or BSD mail.

On 2013-11-06 22:56, sean m wrote:
>
> It should be pointed out that if you’re having problems with this
> working on any distro, make sure you have the heirloom-mailx
> implementation installed, not the GNU or BSD mail.

No need. openSUSE replaced mail with mailx years ago.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)