{"id":8718,"date":"2020-06-27T09:11:51","date_gmt":"2020-06-27T13:11:51","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=8718"},"modified":"2021-12-04T08:35:40","modified_gmt":"2021-12-04T08:35:40","slug":"bash-mail-command-not-found","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/bash-mail-command-not-found\/","title":{"rendered":"Bash mail: command not found: CentOS, Redhat, Ubuntu, and Debian"},"content":{"rendered":"\n
The bash mail: command not found error can be triggered usually in fresh or minimal installations of any Linux<\/a> operating system. The reason for this is the operating system<\/a> vendors tend to include the bare minimum programs, tools, and utilities to make the system operational.<\/p>\n\n\n\n The side-effect of this is that you are left without the option to send mail from the command line should you require to do it directly or through a bash script.<\/p>\n\n\n\n There are other programs that can be used to send emails in Linux however today we are focusing on the mail command utility.<\/p>\n\n\n\n For those with Red hat (RHEL) based systems, this command is installed from mailx rpm packages while for those on Debian-based systems the command will be installed from the mailutils<\/em> package.<\/p>\n\n\n\n Install mail command on CentOS\/Redhat:<\/p>\n\n\n\n Install mail command on Ubuntu\/Debian<\/p>\n\n\n\n After installing mail command packages on your system, you may want to send a test email using the below example.<\/p>\n\n\n\n You can specify the sender using the command below:<\/p>\n\n\n\n You can also load the message body from a file using the command below:<\/p>\n\n\n\n In most cases, this is sufficient for simple diagnostics and alerts mailing you can use from your bash scripts. To handle more business kind use cases you may need other programs such as Postfix, Sendmail, Dovecot, fail2ban, and other systems to handle sending, receiving, and spam management.<\/p>\n\n\n\n Anyway, that is how you install and use the bash mail command in Linux operating systems such as CentOS, Redhat, Ubuntu, and Debian among others.<\/p>\n","protected":false},"excerpt":{"rendered":" The bash mail: command not found error can be triggered usually in fresh or minimal installations of any Linux operating system. The reason for this is the operating system vendors…<\/p>\n","protected":false},"author":1,"featured_media":8719,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,28,16,18],"tags":[121,184,193,219,354,363,431,433,573,591,598,604],"yoast_head":"\nInstall Bash Mail Command<\/h2>\n\n\n\n
$ sudo yum install mailx<\/code><\/pre>\n\n\n\n
$ sudo apt-get install mailutils<\/code><\/pre>\n\n\n\n
Send a Test Email to Confirm<\/h2>\n\n\n\n
$ echo "Message Body" | mail -s "Message Subject" recipient@example.com<\/code><\/pre>\n\n\n\n
$ echo "Message Body" | mail -s "Message Subject" recipient@example.com -a From:sender@example.com<\/code><\/pre>\n\n\n\n
$ mail -s "Message Subject" recipient@example.com -a From:sender@example.com < \/path\/to\/filename<\/code><\/pre>\n\n\n\n
Conclusion<\/h2>\n\n\n\n