mail a file as attachment


/ Published in: Bash



Copy this code and paste it in your HTML
  1. #!/bin/bash
  2. ## vim:ts=4:sw=4:tw=100:ai:nowrap:formatoptions=croqln:
  3. file=${1}
  4. echo -n "Enter body:"
  5. read body
  6. echo -n "Enter Subject: "
  7. read subject
  8. [[ -z "$body" ]] && { body="Sending attachment using mail"; }
  9. [[ -z "$subject" ]] && { subject="backup: $file "; }
  10. [[ -z "$file" ]] && { echo "Error: file blank." 1>&2; exit 1; }
  11. { echo -e "$body"; uuencode "$file" "$file"; } | mail -s "$subject" ${GMAIL_USER}@gmail.com ;
  12.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.