Last active
December 8, 2016 17:22
-
-
Save casperbiering/dde01a156b1418e7b0f58731b80198cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TO="user@example.com" | |
FROM="user@example.com" | |
SUBJECT="Invalid sending domain on `hostname`" | |
MESSAGE="The attached mail did not comply with our sender domains on `hostname`." | |
TMPFILE=$(mktemp) | |
trap "rm -f $TMPFILE" 0 1 2 3 15 | |
HEADER="To: $TO | |
From: $FROM | |
Subject: $SUBJECT | |
MIME-Version: 1.0 | |
Content-Transfer-Encoding: 7bit | |
Content-Type: multipart/mixed; boundary=\"_----------=_148120056728766463\" | |
This is a multi-part message in MIME format. | |
--_----------=_148120056728766463 | |
Content-Transfer-Encoding: 7bit | |
Content-Type: text/plain; charset=\"utf-8\" | |
$MESSAGE | |
--_----------=_148120056728766463 | |
Content-Disposition: attachment; filename=\"attached.eml\" | |
Content-Type: message/rfc822; name=\"attached.eml\" | |
Content-Transfer-Encoding: 8bit | |
" | |
FOOTER=" | |
--_----------=_148120056728766463-- | |
" | |
echo -e "$HEADER" >> $TMPFILE | |
#cat | base64 -w 60 >> $TMPFILE | |
cat >> $TMPFILE | |
echo -e "$FOOTER" >> $TMPFILE | |
#cat $TMPFILE | |
/usr/sbin/sendmail -t -f $FROM -F "" < $TMPFILE | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment