You can easily send email attachment using mutt mail client. It works from command line or a shell prompt. However mutt is not installed by default. You need to install mutt command. mutt command also works under UNIX and Linux like operating systems. Let us see how to send mail with attachments with mutt on FreeBSD Unix system.
Install mutt under FreeBSD
Mutt is a small but very powerful text based program for reading electronic mail under unix operating systems, including support color terminals, MIME, and a threaded sorting mode. Use the pkg_add command to install binary software package distributions.
Searching for mutt
The command is:
# pkg search mutt
Here is what we see
font-mutt-misc-1.0.3_4 X.Org miscellaneous Mutt fonts mutt-2.0.2 Small but powerful text based program for read/writing e-mail mutt_vc_query-002 vCard query utility for mutt mutter-3.36.6 Window and compositing manager based on Clutter muttprint-0.73_4 Utility to print mail for most any mail client neomutt-20200925_1 Bringing together all the Mutt Code notmuch-mutt-0.31 Integrates the Notmuch email search and tagging application with Mutt rubygem-mutter-0.5.3 Tiny command-line interface library
Installing mutt on FreeBSD
Older FreeBSD users type:
# pkg_add -v -r mutt
For the latest version of FreeBSD, run the following pkg command:
# pkg install mutt
Alternatively, you can use FreeBSD ports collections:
# cd /usr/ports/mail/mutt
# make install clean
Installing mutt to send attachments from FreeBSD jail or cloud server
FreeBSD send mail with attachments
Send reports.tar.gz file to vivek@gmail.co.in as attachment, enter:
$ mutt -s "Reports" -a reports.tar.gz vivek@gmail.co.in < /dev/null
## NOTE: latest version of mutt uses -- before email-id ##
mutt -s "Reports" -a /root/.viminfo -- vivek.gite@gmail.com < /dev/null
OR
$ mutt -s "Subject" -a reports.tar.gz vivek@gmail.co.in < /tmp/mail-message.txt
$ mutt -s "Subject" -a reports.tar.gz -- vivek@gmail.co.in < /tmp/mail-message.txt
Where,
- -a file : Attach a file to your message using MIME.
- -s subject : Specify the subject of the message.
- -- email-id : Attach a file using MIME. Separating file and email-id arguments with “--” is mandatory. For example: mutt -a screenshot.jpg -- you@example OR mutt -a foo.jpg bar.tiff *.png -- you@example1 you@example2-dot-com. The -a option must be placed at the end of command line options.
- < /tmp/mail-message.txt : Read email body text from the /tmp/mail-message.txt file.
- < /dev/null : Send an email without body text.
Sending multiple attachments using mutt on FreeBSD
For multiple file attachments use the -a option for each file as follows:
$ mutt -s "Subject" -a file1.tar.gz -a file2.tar.gz -- vivek@gmail.co.in < /dev/null
How to specify a blind carbon-copy (BCC) address mutt
The syntax is as follows with the -b option:
$ mutt -s "FreeBSD server disk failed" -b alert@sysadmin-email-list -a disk.log.gz -- vivek@gmail.co.in < /dev/null
Specify a carbon-copy (CC) address with mutt
Pass the -c option to the mutt on FreeBSD Unix server:
$ mutt -s "ZFS problem" -c admin@somwhere-com -a zfs.disk.log.gz -- vivek@nixcraft.co.in < /dev/null
Getting help
All you have to do is type the following command:
$ mutt -h
Summing up
For more information read mutt command man page or docs online:
$ man mutt
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 7 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Can a mutt-1.5.19 be installed on a FreeBSD system (where there’s a mutt-1.4.2.3) by a user who doesn’t have root acccess? Using pkg_add or any other way? If so, how? Any tips appreciated. (I tried & got a lot of “permission denied.”)
Noop. You need to be root to install software.
> Noop. You need to be root to install software.
Well, surely there must be some way for users on a FreeBSD system to install programs into their own home directory. If not, then I don’t see much “free” in FreeBSD.
You don’t understand security concept, do you? This is a security feature. Otherwise, it will just like MS-Windows, you can install anything including virus without your permission. I suggest you get a good book which explains basic UNIX concepts.
You can install packages or source to your own home directory; you typically need to be root because, when installing a package/port system-wide (the usual behaviour), you need to place the pieces of this application in different system directories (/usr/bin, /etc, /usr/lib etc.), and this requires root/superuser permissions.
In Windows, users are typically setup as ‘Administrators’, making it easier for them to install new software they want; the software is kept all in one place, in it’s own directory in Program Files, but this is still a system directory and needs Admin (root) privileges. Windows users are encouraged to have an Admin account for installing new software, and a limited User account just for their own space, however in practise nobody really does this because it’s too difficult, and Windows systems as home desktops are really just there for playing games and doing unimportant crap.
In either situation – yes, it would actually be (arguably) better to let users only install applications to their local home directories, for their local use, running them with their own limited credentials; this way, even if you installed a piece of malware, it should only affect you, or at least, be unable to do system-wide damage (or, if you’ve chrooted/jailed your home dir somehow, it shouldn’t be able to get to the outer filesystem either).
But BSD machines, and most Unix systems, are used as serious midrange business servers; only new software that’s been vetted by someone, or is in the standard ports tree to begin with, is installed – by someone with root privileges, and usually as part of a painstakingly complex upgrade process. This is not the same as a personal home Windows desktop system.
TL;DR Needing root privileges to install a package is only to install it system-wide (which it usually is), because the process will need to add files to directories like /usr/bin, /etc, /usr/lib and so on.
One should note that certain versions of mutt require the double-dash after the attachment before the email address — e.g.:
mutt -s "files" -a foo.tar.gz -- first.last@example.com
I updated the page. I appreciate your feedback and comment.