Sending email on RedHat 7 with mailx

To send email from a RedHat 7 server with no email server configured:

Install mailx:

sudo yum install mailx

When there is no email server configured, the mailx command will need to utilize a relay server with the -S option:

mailx -s "Test Email" -S smtp=smtp:// [email protected]

Full example:

$ echo "This is my test message" | mailx -v -s "Test Email" -S smtp=smtp:// [email protected]
Resolving host . . . done.
Connecting to . . . connected.
>>> HELO
>>> MAIL FROM:<[email protected]>
250 sender <[email protected]> ok
>>> RCPT TO:<[email protected]>
250 recipient <[email protected]> ok
>>> DATA
354 go ahead
>>> .
250 ok:  Message 21861950 accepted
>>> QUIT

comments powered by Disqus