Problem
I need the ability to send an email with an attachment
non-interactively. For example, a script, application or
cron job to email an attached file to another email
address automatically.How can I do this? Cause
The standard mail utility on OpenServer and UnixWare cannot attach files to emails.
Another utility must be used.This article describes how to use the mail utility "mutt" to achieve this.
Mutt is a free skunkware product, does not require a license and is unsupported.
Solution
First, the mutt utility must be installed. There are both
OpenServer and UnixWare versions of this utility. For OpenServer5:
---------------
ftp://ftp2.sco.com/pub/skunkware/osr5/vols/mutt-1.2.5.1-VOLS.tarThe OpenServer5 version of mutt requires another skunkware package be installed, ncurses:
ftp://ftp2.sco.com/pub/skunkware/osr5/vols/ncurses-4.2-VOLS.tarUn-tar each utility separately and use the scoadmin software manager, or custom, to install this software.
For OpenServer6:
---------------
ftp://ftp2.sco.com/pub/skunkware/osr6/vols/mutt-1.4.2.1iSa-VOLS.cpioand install as above.Mutt is installed in /bin/muttFor it to work in an MMDF environment, please change:
sendmail="/usr/lib/mail/execmail"in the Muttrc file. For UnixWare7:
-------------
ftp://ftp2.sco.com/pub/skunkware/uw7/mail/mutt/mutt-1.2.5.1.pkgThis package does not need to be un-tared or uncompressed, simply
download it and run "pkgadd -d `pwd`/mutt-1.2.5.1.pkg". Usage:
-----
Standard Method:# mutt -x -a <file to attach> -s <subject> email_addr < mail.body.txtAlternate Method:Once when the software has been installed, the following syntax can be used to send an email, with an attachment to an email address:
# echo "" | mutt -a /dir/file -s "Subject" user@domain.comThis will send an email, with an empty body, to
user@domain.com, with the subject of "Subject" and the
file /dir/file attached to the email. If you wish to have
a body to this email, you can enter it within the first pair of
quotes or you can create a text file and use cat instead
of echo, as in:# cat /dir/body.txt | mutt -a /dir/file -s "Subject" user@domain.comNOTE: The mutt command will also allow you to set the From: sender address
via a muttrc file. To do so, you could create a /dir/muttrc file
with these contents:set use_from
my_hdr From: "System Mail processing" <mail@domain.com>This can then be referenced with mutt using the -F option:
# cat /dir/body.txt |\
mutt -a /dir/file -s "Subject" -F /dir/muttrc user@domain.com See also
TA107230 "MMDF Troubleshooting Techniques". TA107702 "Basic troubleshooting for sendmail".