Ubuntu CLI Mail Command: The program ‘mail’ can be found in the following packages
While working on a clients Ubuntu Linux computer I needed to send some of the logs to myself so I could analyze them at a later date but there was not an SMTP server installed on the computer. This can be resolved by installing the Exim MTA (Mail Transfer Agent) using the below apt-get command which is actually stated fairly clearly in the output of attempting to use the mail command from the Ubuntu CLI as shown below. The initial attempt at using the mail command as well as the output from apt-get is displayed in the below example output.
Ubuntu Linux: The program ‘mail’ can be found in the following packages
root@user-desktop:/home/user/lilypond/scripts# more lilyscript.py | mail email@example.com The program 'mail' can be found in the following packages: * heirloom-mailx * mailutils Try: apt-get install <selected package> root@user-desktop:/home/user/lilypond/scripts#
As you can see above the output from attempting to use the mail command from the Ubuntu Linux CLI returns the actual command to install packages that include the mail command. Below is output from installing mailutils and the required dependencies.
Install mailutils Using apt-get On Ubuntu Linux:
root@user-desktop:/home/user# apt-get install mailutils Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: exim4 exim4-base exim4-config exim4-daemon-light libgsasl7 libmailutils2 libntlm0 Suggested packages: eximon4 exim4-doc-html exim4-doc-info libmail-spf-query-perl swaks mailutils-mh Recommended packages: mailx The following NEW packages will be installed: exim4 exim4-base exim4-config exim4-daemon-light libgsasl7 libmailutils2 libntlm0 mailutils 0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded. Need to get 3,528kB of archives. After this operation, 8,782kB of additional disk space will be used. Do you want to continue [Y/n]? Y Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main exim4-config 4.71-3ubuntu1 [374kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/main exim4-base 4.71-3ubuntu1 [1,007kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/main exim4-daemon-light 4.71-3ubuntu1 [501kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/main exim4 4.71-3ubuntu1 [7,948B] Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libntlm0 1.1-1 [18.1kB] Get:6 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libgsasl7 1.4.4-1ubuntu1 [188kB] Get:7 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libmailutils2 1:2.1+dfsg1-4ubuntu1 [1,042kB] Get:8 http://us.archive.ubuntu.com/ubuntu/ lucid/universe mailutils 1:2.1+dfsg1-4ubuntu1 [390kB] Fetched 3,528kB in 3s (1,069kB/s) Preconfiguring packages ... Selecting previously deselected package exim4-config. (Reading database ... 221998 files and directories currently installed.) Unpacking exim4-config (from .../exim4-config_4.71-3ubuntu1_all.deb) ... Selecting previously deselected package exim4-base. Unpacking exim4-base (from .../exim4-base_4.71-3ubuntu1_i386.deb) ... Selecting previously deselected package exim4-daemon-light. Unpacking exim4-daemon-light (from .../exim4-daemon-light_4.71-3ubuntu1_i386.deb) ... Selecting previously deselected package exim4. Unpacking exim4 (from .../exim4_4.71-3ubuntu1_all.deb) ... Selecting previously deselected package libntlm0. Unpacking libntlm0 (from .../libntlm0_1.1-1_i386.deb) ... Selecting previously deselected package libgsasl7. Unpacking libgsasl7 (from .../libgsasl7_1.4.4-1ubuntu1_i386.deb) ... Selecting previously deselected package libmailutils2. Unpacking libmailutils2 (from .../libmailutils2_1%3a2.1+dfsg1-4ubuntu1_i386.deb) ... Selecting previously deselected package mailutils. Unpacking mailutils (from .../mailutils_1%3a2.1+dfsg1-4ubuntu1_i386.deb) ... Processing triggers for man-db ... Processing triggers for doc-base ... Processing 3 added doc-base file(s)... Registering documents with scrollkeeper... Processing triggers for ureadahead ... ureadahead will be reprofiled on next reboot Setting up exim4-config (4.71-3ubuntu1) ... Adding system-user for exim (v4) Setting up exim4-base (4.71-3ubuntu1) ... Setting up exim4-daemon-light (4.71-3ubuntu1) ... * Starting MTA [ OK ] Setting up exim4 (4.71-3ubuntu1) ... Setting up libntlm0 (1.1-1) ... Setting up libgsasl7 (1.4.4-1ubuntu1) ... Setting up libmailutils2 (1:2.1+dfsg1-4ubuntu1) ... Setting up mailutils (1:2.1+dfsg1-4ubuntu1) ... update-alternatives: using /usr/bin/frm.mailutils to provide /usr/bin/frm (frm) in auto mode. update-alternatives: using /usr/bin/from.mailutils to provide /usr/bin/from (from) in auto mode. update-alternatives: warning: not replacing /usr/bin/from with a link. update-alternatives: warning: not replacing /usr/share/man/man1/from.1.gz with a link. update-alternatives: using /usr/bin/messages.mailutils to provide /usr/bin/messages (messages) in auto mode. update-alternatives: using /usr/bin/movemail.mailutils to provide /usr/bin/movemail (movemail) in auto mode. update-alternatives: using /usr/bin/readmsg.mailutils to provide /usr/bin/readmsg (readmsg) in auto mode. update-alternatives: using /usr/bin/dotlock.mailutils to provide /usr/bin/dotlock (dotlock) in auto mode. update-alternatives: using /usr/bin/mail to provide /usr/bin/mailx (mailx) in auto mode. Processing triggers for libc-bin ... ldconfig deferred processing now taking place root@user-desktop:/home/user#
As seen above there are a bunch of dependencies that need to be installed but it actually happens fairly quick. During the installation process Exim MTA will start automatically. Please note that after the above installation process you will still not be able to send email from the server to external locations since the default configuration of Exim won’t allow this. For information on configuring Exim to allow sending email to external locations read this QD article on configuring Exim to send mail externally. It is highly recommended to investigate Postfix instead of Exim if you plan on using the MTA on a regular basis.