"mailx" Command - Send and Read Emails

This section provides a tutorial example on how to install and use 'mailx' on CentOS computers to read and send emails locally or remotely via IMAP/POP and SMTP protocols.

What Is "mailx" Command? - "mailx" command is an enhanced version of the old "mail" command. "mailx" command can:

1. Install "mailx" on CentOS computer.

herong$ sudo dnf install mailx

2. Read local emails in mailbox format. No emails found.

herong$ mailx

No mail for herong

3. Read local emails in Maildir/ format.

herong$ mailx -f Maildir

Heirloom Mail version 12.5 7/5/10.  Type ? for help.
"Maildir": 3 messages 1 unread
    1 herong@example.com  Nov 15 11:55  12/376
    2 herong@example.com  Nov 15 12:13  19/681   "Test #2"
>U  3 herong@example.com  Nov 15 12:14  28/930   "test #3"

& 1
Message  1:
From herong@example.com Nov 15 11:55:18 2020
Return-Path: <herong@example.com>
X-Original-To: herong
Delivered-To: herong@example.com
Date: Nov 15 2020 11:55:18 +0800 (CST)
From: herong@example.com
Status: RO

Hello!

& q

4. Send an email through local agent.

herong$ mailx herong

Subject: Hello again
From Mailx
.
EOT

5. Read remote emails from a POP3 server.

herong$ mail -f Maildir/

Heirloom Mail version 12.5 7/5/10.  Type ? for help.
"Maildir": 3 messages 1 unread
    1 herong@example.com  Nov 15 11:55  12/376
    2 herong@example.com  Nov 15 12:13  19/681   "Test #2"
>U  3 herong@example.com  Nov 15 12:14  28/930   "test #3"

& folder pop3://localhost:110
User: herong
Password: TopSecret
"pop3://localhost:110": 2 messages 2 new
>N  1 herong@example.com     Mon Nov 23 11:55    /386
 N  2 herong@example.com     Tue Nov 24 15:21    /519   "Hello 2"
& q

6. Send an email through a SMTP server.

herong$ mailx -S smtp="localhost:25" herong@example.com

Subject: Hello 3
From STMP
.
EOT

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

Email Client Tools - Mail User Agents (MUA)

"mailx" Command - Send and Read Emails

 "Alpine" - Terminal-Based Email Client

 Thunderbird Installation on macOS

 Thunderbird Configuration for POP3S and SMTP

 Thunderbird to Accept POP3S Certificate Exception

 Thunderbird Configuration for IMAPS and SMTP

 Thunderbird Configuratin for SMTPS Service

 macOS Mail Auto Configuration

 macOS Mail Manual Configuration

 Accept Certificate Exception in macOS Mail

 Windows 10 Mail Configuration Failed

 SSL/TLS Connection Issue in Windows 10 Mail

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB