Hackonology Forums
How to easily send e-mails via mailx - Printable Version

+- Hackonology Forums (https://hackonology.com/forum)
+-- Forum: Technology & Configuration (https://hackonology.com/forum/forumdisplay.php?fid=3)
+--- Forum: System Configuration (https://hackonology.com/forum/forumdisplay.php?fid=4)
+--- Thread: How to easily send e-mails via mailx (/showthread.php?tid=597)



How to easily send e-mails via mailx - SysAdmin - 07-22-2021

So far I’ve been pretty fine with having postfix to relay my emails from command line, but today I’ve learned that the tool I use for sending emails from cron (mailx) can be easily configured to relay the mail directly. It’s super easy:

Code:
$ cat ~/.mailrc
set smtp-use-starttls
set smtp=smtp://smtp.xxx.redhat.com:587
set from=xxx@redhat.com


That’s all. To test the delivery use -v option:
Code:
echo "How you doin?" | mail -v -s Test xxx@redhat.com
Resolving host smtp.xxx.redhat.com . . . done.
Connecting to 10.4.203.49:587 . . . connected.
220 smtp.xxx.redhat.com ESMTP Postfix
>>> EHLO box
250-smtp.xxx.redhat.com
250-PIPELINING
250-SIZE 30000000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
>>> STARTTLS
220 2.0.0 Ready to start TLS
>>> HELO box
250 smtp.xxx.redhat.com
>>> MAIL FROM:<xxx@redhat.com>
250 2.1.0 Ok
>>> RCPT TO:<xxx@redhat.com>
250 2.1.5 Ok
>>> DATA
354 End data with <CR><LF>.<CR><LF>
>>> .
250 2.0.0 Ok: queued as 89664600CC
>>> QUIT
221 2.0.0 Bye