The mailx command is a client email (MUA) that is officially known as the Heirloom mailx 1).
It supports:
With an Interactive shell and the to address 2):
mailx [email protected] [email protected]
Subject: Fees
Tuition fees are due next Friday. Don't forget!
<Control-d>
EOT
You can send an email via the local server (ie localhost:25) with mailx by:
echo "This is a test mail. Hallo Charlie" | mail -s "Subject: A big test" [email protected]
Via the input redirect operator and smtp server properties
env MAILRC=/dev/null \
from=scriptreply@domain \
smtp=host \
smtp-auth-user=login \
smtp-auth-password=secret \
smtp-auth=login \
mailx -n -s "subject" \
-a attachment_file recipient@domain < content_file.txt
By default, mailx invokes sendmail directly to transfer messages. If the smtp variable is set a SMTP connection to the server specified by the value of this variable is used instead.