I am working with a locked-down RHEL box.
The goal is to send an email with a file attached.
The only mail service available is sendmail (cannnot use sendemail, mail, mailx, mutt, etc.)
In addition, the uuencode command cannot be found and I cannot install sharutils.
I have verified that sendmail works with the simple test below:
echo "Subject: testing" | sendmail -v [email protected]
I have tried the command below but it just creates a dead.letter:
echo "Subject: testing" | sendmail /a /tmp/test.txt [email protected]
What is the correct way to send a file from the server using sendmail given the constaints?
The work-around was to use openssl base64 encoding like so:
( echo "to: [email protected]"
echo "subject: Message from the server"
echo "mime-version: 1.0"
echo "content-type: multipart/related; boundary=messageBoundary"
echo
echo "--messageBoundary"
echo "content-type: text/plain"
echo
echo "Please find the document attached."
echo
echo "--messageBoundary"
echo "content-type: text; name=test.txt"
echo "content-transfer-encoding: base64"
echo
openssl base64 < /tmp/test.txt) | sendmail -t -i
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments