Skip to content

Instantly share code, notes, and snippets.

@maimai-swap
Created March 3, 2014 06:35
Show Gist options
  • Save maimai-swap/9319546 to your computer and use it in GitHub Desktop.
Save maimai-swap/9319546 to your computer and use it in GitHub Desktop.
mutt mail send with a attached file of text.
#!/bin/sh
dir=/home/ec2-user/tmp
filepath=$dir/testfile.csv
Err(){ echo "$1">&2; exit 1; }
mail_to='[email protected]'
mime=`file --mime $filepath | cut -d' ' -f2`
filename=`basename $filepath`
echo "mime-type=$mime"
echo "filename=$filename"
echo "filepath=$filepath"
# check file
if [ -e $filepath ]; then
cd $dir
echo "mail body with attached file..." | mutt -s "test mail title" -a "$filepath" -- $mail_to
else
Err "Warning : Cannot open ${filepath}"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment