Skip to content

Instantly share code, notes, and snippets.

Last active June 18, 2021 19:57
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Bash shell script to mail a copy of a web page's HTML so it will render correctly in most native email programs (but not in web-mail).
# Examples:
# 'An Example Page'
# 'Passworded Page' --user=john --password=xxxxx
set -eu
USAGE=$'\n'"Usage: $(basename $0) URL address subject [ wget options ]"
URL=${1:?"Missing URL.$USAGE"}
ADDRESS=${2:?"Missing Address.$USAGE"}
SUBJECT=${3:?"Missing Subject.$USAGE"}
shift 3
trap 'rm -f "$OUT"' EXIT
wget --no-verbose --convert-links --output-document="$OUT" $WGET_ARGS "$URL" 2>&1
mail -a 'MIME-Version: 1.0' -a 'Content-type: text/html; charset=utf-8' -s "$SUBJECT" "$ADDRESS" < "$OUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment