• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Send Mails To an External User With Mailx on Linux

by admin

Question: How to send emails to external users with mailx running on CentOS/RHEL system?

The following command shows how to send a mail to an external user using mailx:

# echo "this is the body of the email" | mailx -vvv -s "test mail" -r "From" -S smtp="your-smtp" someone@address

Here,
-vvv = Verbosity.
-s = Specifies the subject.
-r = Email sent from.
-S = Specifies the smtp server.

To be able to send mails out of the internal network using mailx, the external relay or smtp that is going to be handling all mails, needs to be specified in order for emails to be delivered to the correct address.

You can also edit the mailx config file /etc/mail.rc to add the following configuration to the end of the file, e.g.:

set smtp=your.smtp.server
set from="from email address"

Then run the mailx command and then enter the body of the email, hit enter, and finally press Ctrl+D to deliver it.

# mailx -vvv -s "email subject"  external-email-address
 
[Body of the email]

Ctrl D to deliver the message

Filed Under: Linux

Some more articles you might also be interested in …

  1. chmod: command not found
  2. unshadow: command not found
  3. qemu-system-x86_64: command not found
  4. calibredb: Tool to manipulate the your e-book database
  5. geth: The go-ethereum command-line interface
  6. DHCP configuration file /etc/dhcp/dhcpd.conf explained
  7. How to Lock and Unlock Zimbra Accounts from Command Line
  8. lynis: command not found
  9. tcpdump: command not found
  10. git checkout: Checkout a branch or paths to the working tree

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright