Mail command to send attachements

aixmail-commandsendmail

I tried the below command

uuencode data.txt | mailx –s “Test Mail” “mrp@xyz.com”

But I get the below error

ksh: uuencode: not found.
Null Message body;  hope that' ok

which clearly tell that uuencode utility is not found.

I there any other way to send attachments with mail through command line. At the same time I don't have admin access for the same to install the utility (I use AIX 5. version Server)

Best Answer

mailx can not send attachments and you don't have uuencode. If you have mime-construct, then it is relatively easy:

 mime-construct --output \
                --to "bernhard@localhost" \
                --file-attach fish.zip \
                --string here_you_are

the output:

To: bernhard@localhost
MIME-Version: 1.0 (mime-construct 1.9)
Content-Type: multipart/mixed; boundary=congratulations

--congratulations
Content-Disposition: attachment; filename=fish.zip
Content-Type: application/zip; name=fish.zip
Content-Transfer-Encoding: base64

UEsDBBQAAgAIADKluEK3tLL0XAAAAG8AAAAEABUAZmlzaFVUCQADYLSfUSKiAVNVeAQAAAAAAC2K
wQ2AIBAE/1axDSB8tBMLIHDoJXIQOSV2ryb+JjPDHZEu9N2LA4vSkXwg+BiRuG0OeldCLsJaDqTd
rw1ShAYNNZ65wvA/moZ5cu6FVy4wHbCaq/0qyzp+9/AAUEsBAhcDFAACAAgAMqW4Qre0svRcAAAA
bwAAAAQADQAAAAAAAQAAAKSBAAAAAGZpc2hVVAUAA2C0n1FVeAAAUEsFBgAAAAABAAEAPwAAAJMA
AAAAAA==

--congratulations
Content-Transfer-Encoding: base64

aGVyZV95b3VfYXJl

--congratulations--

together with mailx:

mime-contruct --your-options | mailx -s your_subject youruser@domain
Related Question