Advertisement
teknoraver

scan2mail

Sep 9th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. [ $# -ne 1 ] && exec echo "Usage: $0 <address>"
  4. boundary=$(hexdump -n16 -e '1 "%02x"' /dev/urandom)
  5. date=$(date '+%d-%m-%Y %R')
  6.  
  7. {
  8. cat <<EOF
  9. From: Scan
  10. To: $1
  11. Subject: Scansione $date
  12. MIME-Version: 1.0
  13. Content-Type: Multipart/Mixed; boundary="$boundary"
  14.  
  15. --$boundary
  16. Content-Disposition: inline
  17. Content-Transfer-Encoding: 7bit
  18.  
  19. Allegato
  20. --$boundary
  21. Content-Type: image/jpeg
  22. Content-Transfer-Encoding: base64
  23. Content-Disposition: attachment; filename="scan-$date.jpg"
  24.  
  25. EOF
  26. scanimage --mode Color --format jpeg |base64
  27. echo "--$boundary--"
  28. } |sendmail "$1" 2>/dev/null >/dev/null &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement