• 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

Mutt, Mail and Telnet – Send mails from linux command line or terminal

by admin

Mutt

Mutt is a small but powerful text-based e-mail client for Unix-like operating systems. With the mutt command, one can send and read emails. Mutt supports both maildir & mbox mail formats. Mutt is compatible with POP & IMAP protocols.

Syntax

# mutt -s "Subject of the Mail" recipient-address@domain.com < /dev/null

Example 1: Send a test mail where the mail body is blank:

# mutt -s "Test Mail" thegeekdiary@gmail.com < /dev/null

Above Command will send a mail with subject “ Test Mail” to thegeekdiary@gmail.com

Example 2: Send Mail with attachments.
Syntax :

# mutt -s "Subject of the Mail" -a  /tmp/[file-to-be-attached] recipient-address@domain.com < /tmp/[mail body contents file]

Example:

# mutt  -s "test mail plz ignore" -a /tmp/backup.tgz  thegeekdiary@gmail.com 
NOTE: When we send mail from the console, the mail sender name will be root(in case if we are logged in with root user) if we want to change the sender name and email, then Create a file in user’s home directory.
# cat .muttrc
set from = "noreply@tgdmail.com"
set realname = "MAIL ADMIN"

Mail

Mail is an e-mail client, which is used to send and receive mails.

Syntax

# mail  -s [subject] -c [cc-addr] -b [bcc-addr] to-addr... < /mailbody.txt

Example:

# mail -s "test mail plz ignore" thegeekdiary@gmail.com 

Above Command will send a mail with subject “test mail plz ignore” and body of mail will be the contents of /tmp/body.txt file.

Telnet

The telnet command is used to communicate with another host using the TELNET protocol. Telnet can be used to send emails, as shown below:

mutt and mail commands in Linux

Where:

  • mail from: specify the e-mail id from where the mail will be send.
  • rcpt to: specify the recipient email-id.
  • data: it is the command after which we can specify the subject of the mail.
  • Subject: subject of the mail.
  • quit: is the command to exit.

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 7 : Configuring NTP using chrony
  2. How to mount and umount a file system in Linux
  3. ps Command Examples in Linux
  4. egrep Command Examples in Linux
  5. CentOS / RHEL : How to delete a volume group in LVM
  6. How to Configure a Fiber-Channel Over Ethernet (FCoE) Interface in CentOS/RHEL
  7. yum Command Examples in Linux
  8. ping not working on a Newly Built CentOS/RHEL server
  9. How to use ‘yum’ to connect ULN on CentOS/RHEL/OEL 6
  10. ldd Command Options in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qemu-system-x86_64: command not found
  • timedatectl: command not found
  • mpirun.openmpi: command not found
  • startkde: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright