Advertisement
uriel1998

CLI e-mail to Tbird

Sep 25th, 2011
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.26 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # To send via e-mail from Tux Commander (or Midnight Commander, or the command line)
  4. # using this format:
  5. # admin@box:$ thunderbird –compose “to=’foo@bar.com,bar@foo.com’,subject=’nice tip’,attachment=’file:///home/admin/tip.txt’,body=’Check out this neat command line tip’”
  6. # - so you could probably use zenity to input e-mail addresses and the like as well.
  7. # Tux Commander passes a full filename as $1; from the commandline it will cope with relative and absolute paths as well.
  8. # (Format ganked from http://www.kbrandt.com/2008/05/quick-tip-tunderbird-email-from-command.html)
  9.  
  10.  
  11. # if $1 is a file then it's an attachment
  12. # This is what the script is actually used for, but you could test for e-mail addresses and
  13. # the like this way.
  14. if [ -f "$1" ]; then
  15.  
  16.     # Testing for absolute vs. relative path
  17.     # assuming that relative path starts from PWD.
  18.     case $1 in
  19.         /*)
  20.         file=$1
  21.         absolute=1
  22.         ;;
  23.  
  24.         *)
  25.         absolute=0
  26.         file=$(pwd)/${1#.}
  27.         ;;
  28.     esac
  29.     filename=$(echo "file://$file")
  30.     # currently goes right into mail loop - I want to populate subject, etc, in thunderbird.
  31.     # if you want to do more, then populate each of the variables elsewhere.
  32.     # mailing commandline
  33.     thunderbird -compose "attachment=$filename"
  34. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement