Table of Contents

About

The mailx command is a client email (MUA) that is officially known as the Heirloom mailx 1).

It supports:

How can I send an email with Mailx?

Interactive Shell

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

With Pipe and a local smtp server

You can send an email via the local server (ie localhost:25) with mailx by:

  • piping the content into the mailx application
  • defining:
    • the subject with the s option
    • the to email as last argument
echo "This is a test mail. Hallo Charlie" | mail -s "Subject: A big test" [email protected]

With the input redirect operator and smtp server login

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

How mailx transfers messages?

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.