About Linux FAQ

Browse More FAQs:

FreeBSD send mail with attachments from command line / shell prompt

Posted by Vivek Gite [Last updated: October 3, 2007]

Q. I need to send 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?

A. 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 commands.

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 pkg_add command for installing software package distributions. Type the following command to install mutt:
# 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 vivek@gmail.co.in
$ mutt -s "Reports" -a reports.tar.gz vivek@gmail.co.in
OR
$ 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.

For multiple file attachments use -a for each file:
$ mutt -s "Subject" -a file1.tar.gz -a file2.tar.gz vivek@gmail.co.in

For more information read mutt command man page.

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Other Helpful FAQs:

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.