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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. DNS configuration file /etc/named.conf explained
  2. lvrename Command Examples in Linux
  3. How to connect to an Active Directory Domain using Realmd (Configure CentOS/RHEL 7 as active directory client)
  4. cpupower Command Examples in Linux
  5. How to use command redirection under Linux
  6. pkginfo Command Examples in Linux
  7. How to Disable “Predictable Network Interface Device Names” in CentOS/RHEL 7
  8. pacaur Command Examples in Linux
  9. pkill Command Examples in Linux
  10. pkill: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright