Send file attachement in mail

Hello,

I am able to attache the file in UNIX/LINUX script using following code.

MAILFORMAT="Please do not replay this mail.This mail is auto generated."
 
echo -e $MAILFORMAT | mailx -r autoreplay@gmail.com -a filename -s "status" xyz@gmail.com
 

But same I am not able attache the file in Sunos system in script.

Please advise. :slight_smile:

u need to use uuencode for attaching files in mail

uuencode sample sample |mailx -r autoreplay@gmail.com -s "status" xyz@gmail.com

Most modern email clients do not understand uuencode. I found a perl script some some ago which can compute attachments in modern base64 form.

Thanks Zozoo,

But in SunOs it is not working. Please advice to attach the file in mail for Sunos system.

it works for me fine in Solaris
u can try

uuencode

then pipe it to

mail

---------- Post updated at 01:30 PM ---------- Previous update was at 12:40 PM ----------

u can try for other methods from below link

http://www.shelldorado.com/articles/mailattachments.html
1 Like

Solaris mailx does not have -a option.
But the following seems to work

MAILFORMAT="Please do not replay this mail.This mail is auto generated."
FILENAME=file.csv

mailx -r autoreplay@gmail.com -s "status" xyz@gmail.com << _EOM
$MAILFORMAT

`uuencode $FILENAME $FILENAME`
_EOM
1 Like

Thanks ZoZoo,

There was problem with environment, but now it is working fine.

your link is very useful ...... :slight_smile: