

To send a message with attachment, run the command below. Here are some ways you can send mail using Linux mail utility (mailutils package) on Ubuntu Linux. As an example you can send daily php error logs (with some cap) to your email. Linux command line tools to send mails are very handy for sending mails from bash scripts. Mpack encodes the named file in one or more MIME messages and sends the message to one or more recipients, or writes it to a named file or set of files, or posts it to a set of newsgroups. Linux sending mail from command using mailutils. $ echo "Message Body Here" | mailx -s "Subject Here" -a backup.zip 4. Now send the attachment mail from the command-line using mailx command. Mailx works more like the mutt command and it it also a part of mailutils (On Debian) package.
INSTALL MAIL COMMAND IN LINUX HOW TO
If you found yourself working mainly from CLI, you may find useful to learn how to install and configure Mutt, a command line email client: that’s what we will do in this tutorial. Read more about Mutt – A Command Line Email Client to Send Mails from Terminal 3. Email reader programs such as Thunderbird or Evolution are great, but sometimes they can feel bloated. $ echo "Message Body Here" | mutt -s "Subject Here" -a backup.zip You can send an email with attachment using the mutt command below. If you do not have it on your system, type the command below to install it: $ sudo apt-get install mutt Mutt is a popular, lightweight command line email client for Linux. You can as well send an existing message from a file as follows: $ mail -s "Subject here" -t -A backup.zip < message.txt Second, I found that by using the 'man mail' command and searching for 'attach'. First, Ubuntu 14.0.4 mail from mailutils supports this: mail -A filename -s 'subject'. $ echo "Message Body Here" | mail -s "Subject Here" -A backup.zip There are a lot of answers here using mutt or mailx or people saying mail doesnt support '-a'. Now its time to send an email attachment using mail command a shown. Mail is part of the mailutils (On Debian) and mailx (On RedHat) package and it is used to process messages on the command line. $ mail -s "Hello World", < body.Below are the various, well known methods of sending email with attachment from the terminal. Keep in mind that there may be more than two recipients.


In this example we will send email both to the and. $ cat body.txt | mail -s "Hello World" Set Multiple RecipientĪnother useful feature of mail command is providing multiple recipients by simply delimiting recipients emails. Trying to install pine on our linux mail server but the yum install libldap.so.2 command give the following error: Setting up Install Process Parsing package install arguments No package libldap.so.2 available. There is other way to send mail by redirecting body content with pipe like below. How are you? I hope your pageviews are good.Īnd we send $ mail -s "Hello World" < body.txt sudo apt install mailutils The following command will show the version of this command if it is installed in the system. Run the following command to install mail command. This command is not installed on Ubuntu by default.

In this example body.txt file contains body part of the mail. The most common command for sending email in Linux is mail command. Body part can be read from a file by simply redirecting the content to the mail command like below. But if it is long and repetitive task we do not want to do always there is an alternative. While sending email there will be body part of the mail. In order to work properly we should install the bsd-mailx package like below. Linux distributions provides two mailx command one from the mailutils package which is installed by default and the other one is from the bsd-mailx package. Mail Client Sender -> MTA of sender -> MTA receiver -> Mail Client Receiver Install mailx Command there are some protocol used to accomplish these tasks like smtp,pop3,imap etc.īelow are some architectural view of a simple email transmission.
