How to Send an Email (Mail Message) from Linux Command Line Shell
Occasionally system administrator may need to send a test email, or emergency mail message right from the shell or command line interpreter when using a Linux flavor or distribution of operating system, be Red Hat Fedora, Ubuntu, Debian, CentOS, Open SUSE, FreeBSD and others. In this case, the mail command will come in handy.
mail is a command to send and receive mail in Unix, Linux and BSD operating system. To initiate a mail sending process, just type in the following command:
mail recipient@domain.com
Obviously, replace recipient@domain.com with a valid email address.
The system will prompt for a subject of the email before allowing user to type in the mail message body.
# mail receipent@domain.com
Subject: For Testing Only
This email is for testing the mail delivery system only.
^D (EOT)
Cc:
Once finished typing the email message, press Ctrl-D (shown as ^D in example above), which represents End of Text (EOT). Depending on system, mail may or may not prompt another input request for any recipients to cc (carbon copy) to. Press Enter to skip or accept the input, and get the mail sent.
Tip: If the sender and recipient is on the same system, it’s possible to omit the domain (@domain.com) part of the address, leaving only user name.
It’s also possible to use mail’s arguments or switches to directly send mail without interactive input. For example,
mail -s Test address@domain.com < /dev/null
Command above will immediately send a blank email with empty body to the recipient address with the subject "Test". For more arguments, type "man mail".
Related Articles
- Send an Anonymous Email Message With Web Based Anonymous Mail Service Providers
- Windows Media Center Shell (ehshell.exe) Command Line Switches and Options
- Delay Sending of Email Message in Microsoft Outlook (Supports Gmail, Hotmail, Yahoo, AOL and all POP3/IMAP Mail)
- Send Free Text Message With Hundreds of Email to SMS Gateway or Internet Web SMS from Operator
- How to Create Email Account and Receive Mail for Abuse and Postmaster in Google Apps
- How To Send Mail As Hotmail (smtp.live.com) in Gmail
- Remove ESET NOD32 Checked Email Confirmation Tag Message in Email
- Email Bounces Back with “unrouteable mail domain” Error
- Restart or Shutdown Windows (XP, 2000 and Vista) from Command Line or One-Click Shortcut
- Unlimited Email Storage and Infinity Mail Space for Yahoo! Mail










































December 10th, 2009 22:19
908:
A terminal is an electronic or electromechanical hardware device.
A system is accessed in a number of different ways including terminal emulators, terminals or perhaps via a console cable.
Once in a shell, via whichever means, the user types their commands on the command line.
The term “command line” is entirely appropriate here and everyone reading this page understands what said term entails.
July 29th, 2009 06:48
how do i config my sendmail to make it work? i have ubuntu and it wont work without it.
thanks!
June 29th, 2009 00:24
you have to config your sendmail to make it work
June 28th, 2009 11:53
Argh. It’s a Terminal not a commandline.