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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. Linux / UNIX : How to find files which has SUID/SGID set
  2. Yum Fails with “Error: database disk image is malformed” in /var/log/messages
  3. RHEL 7 – RHCSA Notes – System documentation including man, info, and files in /usr/share/doc
  4. CentOS / RHEL : How to resize (extend) existing Physical Volume (PV)
  5. The System Activity Reporter (sar) Command in Linux
  6. 5 Useful Command Examples to Monitor User Activity under Linux
  7. CentOS / RHEL 7 : Booting process
  8. How to configure NTP server and client in CentOS / RHEL 7
  9. How to find Which Process Is Killing mysqld With SIGKILL or SIGTERM on Linux
  10. How to scan newly Assigned LUNs in Multipathd under CentOS / RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  • How To Add Timestamps To dmesg Kernel Boot Log in CentOS/RHEL
  • How to disable ICMP redirects on CentOS/RHEL
  • What are Oracle Key Vault Roles
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary