How do I send an email using command line under Linux?
To send an email from console you need to use the mail command. It is an intelligent mail processing system which has a command syntax reminiscent of ed with lines replaced by messages. To send an email to email@example.com you need to type the following command:
$ mail firstname.lastname@example.org
Subject: Hello Hai, How are you? Take care, Babai Vivek . <Type DOT (.) followed by ENTER KEY> Cc: <Press ENTER KEY>
You need to type . (dot) to send an email. To send contains of file (such as /tmp/message) as mail body, use the following syntax:
$ mail -s 'Hai' email@example.com < /tmp/message
Please note that above command will NOT route an email if you do not have properly configured MTA/email/ISP server that accepts forwarding from your shell account. You can also use gmail account to forward email (i.e. relay email) as described here.
See also:Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop