Skip to content

Instantly share code, notes, and snippets.

@richardsonlima
Last active February 10, 2016 19:30
Show Gist options
  • Save richardsonlima/43f193b61039a80afe1c to your computer and use it in GitHub Desktop.
Save richardsonlima/43f193b61039a80afe1c to your computer and use it in GitHub Desktop.
#!/bin/bash
timestamp=$(date +"%d-%m-%Y")
export MAILFROM="relatoriodiario@EMPRESAit.com.br"
export MAILTO="contato@gmail.com,user01@gmail.com"
export SUBJECT="[ EMPRESAIt ] Linux ATI - Relatorios diarios da rede x.y.z.x"
export BODY="/home/EMPRESAit/Scripts/CheckDiarioTodasMaquinas/xyzx-dailycheck/body/build.html"
export ATTACH="/var/www/relatorio-xyzx/CheckDiario-REDExyzx-$timestamp.zip"
export MAILPART=`uuidgen` ## Generates Unique ID
export MAILPART_BODY=`uuidgen` ## Generates Unique ID
(
echo "From: $MAILFROM"
echo "To: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
echo ""
echo "--$MAILPART"
echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
echo ""
echo "--$MAILPART_BODY"
echo "Content-Type: text/plain; charset=ISO-8859-1"
echo "You need to enable HTML option for email"
echo "--$MAILPART_BODY"
echo "Content-Type: text/html; charset=ISO-8859-1"
echo "Content-Disposition: inline"
cat $BODY
echo "--$MAILPART_BODY--"
echo "--$MAILPART"
echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'
echo "Content-Transfer-Encoding: uuencode"
echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
echo ""
uuencode $ATTACH $(basename $ATTACH)
echo "--$MAILPART--"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment