Created
August 24, 2016 15:26
-
-
Save jschpp/e21bbd9d40667764be4cbc0f8b72bf52 to your computer and use it in GitHub Desktop.
Takes a markdown file converts it to html and sends it per mutt. Script includes a mail check because I'm prone to typos in mail addresses
This file contains hidden or 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 | |
filename=$1 | |
mail_address=$2 | |
mail_subject=$3 | |
scriptname=`basename "$0"` | |
if [ "$#" -ne 3 ]; then | |
echo "Illegal number of parameters" | |
echo "Usage: $scriptname <filename> <mail_address> <subject_of_mail>" | |
exit 1 | |
fi | |
# check mail | |
# taken mostly from http://stackoverflow.com/a/2138835/343867 on 24-08-2016 17:15 | |
OLDIFS=$IFS | |
IFS="@" | |
set -- $mail_address | |
if [ "${#@}" -ne 2 ];then | |
>&2 echo "invalid email" | |
exit 1 | |
fi | |
domain="$2" | |
dig $domain | grep "ANSWER: 1" 1>/dev/null | |
if [ $? -ne 0 ]; then | |
>&2 echo "domain invalid" | |
exit 1 | |
fi | |
IFS=$OLDIFS | |
pandoc -s -S $filename -t html | mutt -e "set content_type=text/html" -s $mail_subject $mail_address |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment