How to use an external smtp server with Linux mail \ mailx

08 January,2019 by Jack Vamvas

Question: How can I use an external smtp server with Linux mail ?   I'm using the heirloom-mailx implementation on RHEL.

Answer: Here are some examples of using an external smtp server, using the heirloom package on RHEL.

 

--sending an email to an external smtp server - with an attachment 
mail -v -r "root@myserver.net" -s "Test Email with attachment" -S smtp="smtp-xxxx.xxxx.xxxx.net" -a/tmp/hi_jack.txt  "jack@xxxxxx.com"


--sending an email to an external smtp server with multiple recipients
 
mail -v -r "root@mysever.net" -s "Test Email with attachment" -S smtp="smtp-xxxx.xxxx.xxxx.net" -a/tmp/hi_jack.txt  "jack@xxxx.com,kevin@xxxx.com"

--sending an email to an external smtp with message written to body 
echo "Hi Jack" | mail -v -r "root@xxxxx.net" -s "Test Email without attachment" -S smtp="smtp-xxxx.xxxx.xxxx.net"  "jack@xxxxx.com"


Author: Jack Vamvas (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to use an external smtp server with Linux mail \ mailx


dba-ninja.com