sending attachment with mail command

Colin van Niekerk Colin.vanNiekerk at mimecast.co.za
Thu May 14 06:15:28 UTC 2009


Hi Nitin,

Must you use the mail command or can you just any command, mutt may be a better option when dealing with attachments (its sorts out the MIME types for you so you don't need to add extra stuff to your script in order to ensure that the attachment is going to be readable on the other side - more applicable when sending binary attachments through older systems)

Unless it is not installed, you can use mutt as follows in scripts to send a mail with an attachment:

echo "message body goes here" |mutt -s "subject goes here" -a filename_with_full_path_goes_here email at address.goes.here

if you need it to go to many addresses (not limited to 3, this is an example only), use:
echo "message body goes here" |mutt -s "subject goes here" -a filename_with_full_path_goes_here email1 at address.goes.here,email2 at address.goes.here,email3 at address.goes.here

if you need to attach multiple files, just add another -a argument:
echo "message body goes here" |mutt -s "subject goes here" -a filename1_with_full_path_goes_here -a filename2_with_full_path_goes_here -a filename3_with_full_path_goes_here email at address.goes.here

Cheers,
Colin

From: redhat-sysadmin-list-bounces at redhat.com [mailto:redhat-sysadmin-list-bounces at redhat.com] On Behalf Of nitin.gizare at wipro.com
Sent: 14 May 2009 04:39 AM
To: redhat-sysadmin-list at redhat.com
Subject: sending attachment with mail command

HI

I have requirement of sending server logs are attachment using mail command.
Is this possible? if not can some body suggest any other method.


Rgds
Nitin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/redhat-sysadmin-list/attachments/20090514/a30c6fcf/attachment.htm>


More information about the redhat-sysadmin-list mailing list