I need to send a few reports everyday as a mail attachment. I'm using FreeBSD 6.2 server. How do I send mail from a command line or a shell script?
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.
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, enter:
# pkg_add -v -r mutt
Alternatively, you can use FreeBSD ports collections:
# cd /usr/ports/mail/mutt
# make install clean
FreeBsd command line mail attach with mutt
Send reports.tar.gz file to email@example.com as attachment, enter:
$ mutt -s "Reports" -a reports.tar.gz firstname.lastname@example.org < /dev/null
$ mutt -s "Subject" -a reports.tar.gz email@example.com < /tmp/mail-message.txt
- -a file : Attach a file to your message using MIME.
- -s subject : Specify the subject of the message.
For multiple file attachments use -a for each file as follows:
$ mutt -s "Subject" -a file1.tar.gz -a file2.tar.gz firstname.lastname@example.org < /dev/null
For more information read mutt command man page:
$ man mutt
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop