Archief

Berichten met tag ‘xmail’

Bash script to read XMail boxes with Mutt

1 oktober 2007 Reacties uit

For Postmasters: easy way to read a mailbox from your XMail spool. If you have a CDB file (see this post), it is also capable of looking up aliases.

  1.  
  2. readmail real.user@domain.org
  3. #or:
  4. readmail an.alias@domain.org
  5. #or if your RootDomain is domain.org:
  6. readmail an.alias

 

  1.  
  2. #!/bin/bash
  3. XMAILROOT="/var/lib/xmail"
  4. CDB="/var/lib/qpsmtpd/rcptto/validrcptto.cdb"
  5.  
  6. RootDomain=$(grep RootDomain $XMAILROOT/server.tab | awk ‘{print $2}’|sed ‘s/"//g’)
  7. aliaslookup=1
  8. [ -f "$CDB" ] || {
  9.   echo "warning: CDB file not found, alias lookup disabled"
  10.   aliaslookup=0
  11. }
  12. spool="$XMAILROOT/domains/"
  13. if [ -z "$1" ]; then echo usage: $0 user@domain; exit; fi
  14. user=$(echo $1|cut -d@ -f1);
  15. domain=$(echo $1|cut -d@ -f2)
  16. [ "$domain" == "$user" ] && domain=$RootDomain
  17.  
  18. if [ ! -d "$spool/$domain" ]; then
  19.   echo "$domain: no such domain in $spool"
  20.   exit 8
  21. fi
  22.  
  23. if [ ! -d "$spool/$domain/$user" ]; then
  24.   if [ $aliaslookup -eq 1 ]; then
  25.     echo -n "$user@$domain not found, looking for alias: "
  26.     real=$(cdb -qm $CDB $user@$domain)
  27.     if [ $real == "" ];then
  28.       echo "not found"
  29.       exit 8
  30.     else
  31.       echo "using $real"
  32.       user=$(echo $real|cut -d@ -f1)
  33.     fi
  34.   else
  35.     echo "$user: no such user in domain $domain"
  36.     exit 9
  37.   fi
  38. fi
  39.  
  40. mutt -f $spool/$domain/$user/Maildir
Categorie├źn:Linux Tips & Trics Tags:,