What is the MailX (Mail command)?

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.





Discover More
Email - Mail User Agent (MUA) - Mail Client

A Mail User Agent (MUA) is the technical term from a email client application. User agentMail User Agent (MUA)user applicationuser agent on the web A MUA can: read and write in the mailbox and...
Email - Mailbox

A mailbox is a file where the emails message are stored. A user application (known as MUA) can read and write a mailbox The Mail Delivery Agent will write the email received by the SMTP server (MTA)...
What is Sendmail ?

Sendmail was the first well-known SMTP server. The server has the following components: * a mail transfer agent (MTA) to send mail to the outside world * a mail deliver agent (MDA) to receive email...



Share this page:
Follow us:
Task Runner