#!/bin/bash
function create_attachment_block()
{
echo -ne "--$BOUNDARY\r\nContent-Transfer-Encoding: base64\r\n"
echo -ne "Content-Type: $(file -bi "$1"); name=\"$1\"\r\n"
echo -ne "Content-Disposition: attachment; filename=\"$1\"\r\n\r\n$(base64 -w 0 "$1")\r\n\r\n"
}
if [ $# -lt 2 ]; then
echo No files specified...
exit 1;
fi
BOUNDARY="==combine-autogun==_$(date +%Y%m%d%H%M%S)_$$_=="
BODY=""
for a in "$@"
do
if [ -s "$a" -a -f "$a" -a -r "$a" ]; then
BODY="$BODY""`create_attachment_block "$a"`"
fi
done
/usr/sbin/sendmail -oi -t << COMPLEX_MAIL
To: $1
Subject: Please see files attached
MIME-Version: 1.0
User-Agent: $0
Content-Type: multipart/mixed; boundary="$BOUNDARY"
$BODY
--${BOUNDARY}--
COMPLEX_MAIL
According to The Directive 2009/24/EC of the European Parliament and of the Council, and Sec.103(f) of the DMCA (17 U.S.C. § 1201 (f)), the reverse engineering act committed to creating these blog posts is considered legal, as this is an original attempt to improve interoperability, and cannot be waived by license agreements.
The views expressed on this blog are my own and do not necessarily reflect the views of my past and present employers.
2013-12-05
Linux: Send files in e-mail from console
So I wanted to send some files, but my mailx package did not have support for the famous -a parameter.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment