• 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. hashcat Command Examples in Linux
  2. ffsend: Easily and securely share files from command-line
  3. ac – Print statistics on how long users have been connected (Command Examples)
  4. pdfxup Command Examples in Linux
  5. “git am” Command Examples
  6. How to Change Default Permission of /var/log/messages in CentOS/RHEL
  7. i3lock: command not found
  8. lvcreate Command Examples in Linux
  9. How to Run a Script When USB Devices Is Attached or Removed Using UDEV
  10. “az network” Command Examples (Manage Azure Network resources)

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright