Need to send attachment in Mail without using uuencode via script in AIX6.1

Dear All,

Would some one help me with this to send a file as attachment in a mail using a script without uuencode...
I am working on AIX 6.1, the thing is I dont have uuencode available... Is there any other alternate possible way to send file attachment with the mail without using uuencode or without having to install any tools..
Please suggest and also how to...:confused:

I have gone thro' the other posts in the forum, however cudn get one relatively matching this ... Pls advise...

http://www.shelldorado.com/scripts/cmds/sendfile.txt

1 Like

HI Kamaraj...thanks for your response.. however it didn help much.. when i try out based on the second link which u ve provided the content still gets as text in mail not as attachment.. cud u pls let me know on this.. however the other two doesn help on my environment as the requirements to run those are not available... like mutt and metasend, getmimetype arent available.. Is there any other possibility..

This is script i tried now..givin me the content of the file in email rather than attachment***********
#!/bin/ksh
#

( echo "to: receiver_email"
echo "from: sender_email"
echo "subject: sending file.txt"
echo "mime-version: 1.0"
echo "content-type: multipart/related; boundary=xxxRANDOMSTRINGxxx"
echo
echo "--xxxRANDOMSTRINGxxx"
echo "content-type: text/plain"
echo
echo "Body of the message goes here"
echo "Here is filer.txt for your viewing pleasure"
echo
echo "--xxxRANDOMSTRINGxxx"
echo "content-type: text/plain; name=file.txt"
echo "content-transfer-encoding: base64"
echo
openssl base64 < FILENAME ) | sendmail -t -i
*******************************************************************

do you have mutt ?

No mutt too isnt available...

if you have absolutely none of the above commands, and you can't install one of them, you could try a different way,
copy your file to a network share within the script (scp/ftp/locally mounted cifs/nfs share), and send a link with your mail

1 Like

You should consider installing mutt. It is quite easy to do and use. I am far from being an expert, but was able to install it and have incorporated it into my scripts to send attachments. Good luck.

1 Like

Any reason to not just install uuencode ?

You should be able to write an equivalent to uuencode using "iconv" with a destination character set of "uucode".
Then just add the header and trailer:

begin 644 attachment.txt
encodedtext
encodedtext
encodedtext
`
end
1 Like

Dear Methyl,
Due to process and time delay constraints, we are looking to solve the issue asap with other alternate way using available commands/scripts...
Meanwhile Methyl would you please explain about the "iconv" usage in getting the file attached the mail using mailx.. and also i checked and uucode is also not available..Would be of a great help..

Methyl I also tried out the below sampling.. I received the email still with the file content in the body of the message rather than attachment...

cat FILENAME | iconv -f IBM-850 -t ISO8859-1 |mailx -s "stats" mail@address.com

What about using perl or Python

Dear Padow,

I ve not used perl before and I donot have any idea about perl scripting.
So for this case would be possible for u to lemme know with a sample perl script.. the links u had posted were helpful really, however i couldn figure how to customize it for my requirement.. would it be possible for u to help..

The requirement is to send a flat file as text file as an attachment in a mail to the recipients...

In this context, uucode is the name of a character set. It is the character set conversion used by uuencode and uudecode .
Coincidentally there is a an AIX unix command called uucode but it has nothing to do with data conversion.

The syntax for iconv is in man iconv . There is extensive background information about the various converters on the IBM website.
Help - AIX 6.1 Information Center and search for iconv .