Use the following format to send mail using the mpack command without an attachment. This is also straight forward and easy to use.
#The mail command in linux how to#
$ sudo dnf install mpack 3a) How to Use mpack Command on Linux to Send a Mail $ sudo yum install mpackįor “Fedora” system, use the DNF Command to install mpack. The mpack command can be installed from the distribution official repository as follows.įor “Debian/Ubuntu” systems, use APT-GET Command or APT Command to install mpack.įor “RHEL/CentOS” systems, use YUM Command to install mpack. The resulting messages are mailed to one or more recipients. The mpack program encodes the the named file in one or more MIME messages. The mpack is another popular command to send emails from Linux terminal. $ echo "This is the mail body" | mutt -s "Subject" -a test1.txt 3) How to Install mpack Command on Linux Use the following format to send mail using the mutt command with attachment.
$ echo "This is the mail body" | mutt -s "Subject" Use the following format to send mail using the mutt command without an attachment. This is also straightforward and easy to use. $ sudo dnf install mutt 2b) How to Use mutt Command on Linux to Send a Mail $ sudo yum install muttįor “Fedora” system, use the DNF Command to install mutt. $ sudo apt-get install muttįor “RHEL/CentOS” systems, use YUM Command to install mutt.
The mail command can be installed from the distribution official repository as follows.įor “Debian/Ubuntu” systems, use APT-GET Command or APT Command to install mutt. Mutt is a small but very powerful text based program for reading and sending electronic mail under unix operating systems, including support for color terminals, MIME, OpenPGP, and a threaded sorting mode. The mutt is another popular command to send emails from Linux terminal. +-+ 2) How to Install mutt Command on Linux | -s | Specify the subject of the message | | -A | It's used for attachment on Debian based systems. | -a | It's used for attachment on Red Hat based systems. $ echo "This is the mail body" | mail -a test1.txt -s "Subject" +-+-+ Use the following format to send mail using the mail command with attachment. $ echo "This is the mail body" | mail -s "Subject" Use the following format to send mail using the mail command without an attachment. Please let us know if you need something specific you want to achieve, you can send you queries using the comment box below.$ sudo dnf install mailx 1a) How to Use mail Command on Linux to Send a Mail These were some common examples only, there are plenty more applications for the mail command that you can achieve. $ mail -s “File output” it guys, we now end this tutorial on how to use Send mail from the terminal in Linux. To send the contents of the file using the mail command, we will use the following, $ mail -s “File Attached” -A test.txt 4- Sending a file content with mail For example, we need to send a file named ‘test.txt’, so we will use the following command, Now to send a mail with a file as an attachment, we will use option ‘A’ with the mail command. $ mail -s “test mail” 3- Sending a mail with an attachment $ mail -s “test mail” <<< “This is the body of the mail” 2- Send mail to multiple recipientsįor sending mail to more than one user, mention all email addresses followed by a comma. We can also use the following single line command to send mail, Now after you execute the above command, we need to enter the body content & once we are done, press CTRL + D to exit and send the mail. Here, -s option is used for mentioning the subject of mail followed by the email address on which we need to send the mail.