Below is a snippet that works, and gets passed directly to sendmail. In this case it was an ascii text file.
The parenthesis subshell everything so the whole block of text will get passed to sendmail and parsed correctly. Without the headers, just a base64 blob of text would appear to the recipient.
( echo "to: $recipients"
echo "subject: Report for rsync for from_leads on `date`"
echo "mime-version: 1.0"
echo "content-type: multipart/related; boundary=xBoundaryStringx"
echo
echo "--xBoundaryStringx"
echo "content-type: text/plain"
echo "Body Text"
echo "Body Text"
echo "--xBoundaryStringx"
echo "content-type: text/plain; charset=us-ascii; name=$filename"
echo "content-transfer-encoding: base64"
echo
openssl base64 < $filename ) |sendmail -t -i
This was what I had to use to send log attachments on an RHEL 5.8 system that had no mail client supporting attachings, did not have uuencode and was not allowed to have any further packages installed.
This is awesome!!! you rock man. Please keep us being enriched with the ocean of knowledge you have.
ReplyDeleteThis is good
ReplyDeleteThank You. Perfect.
ReplyDeleteThank you, sir.
ReplyDeleteHow to send excel file as an attachment by using the above script?
ReplyDeleteI personally have not tested it, but you might just try attaching the excel sheet as is.
Deletesendmail if not present then ?
ReplyDeleteIt is not working for Linux.. any idea for Linux pls?
ReplyDeleteHey I tried to use this process to send an excel file and wound up with a text file attachment...
ReplyDeletethanks, the scrip run ok with atach file *.txt, but file *.gz not run ok. Do you have suggestions?
ReplyDelete