Advertisement
ReverseFlux

imap

Feb 21st, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # imap_status.sh by drphibes
  4. #
  5. # Script to query dovecot's PREAUTH imap binary for maildir status with an imap STATUS command.
  6. # RFC3501 defines the following valid status items:
  7. #
  8. # MESSAGES
  9. # The number of messages in the mailbox.
  10. #
  11. # RECENT
  12. # The number of messages with the \Recent flag set.
  13. #
  14. # UIDNEXT
  15. # The next unique identifier value of the mailbox. Refer to
  16. # section 2.3.1.1 for more information.
  17. #
  18. # UIDVALIDITY
  19. # The unique identifier validity value of the mailbox. Refer to
  20. # section 2.3.1.1 for more information.
  21. #
  22. # UNSEEN
  23. # The number of messages which do not have the \Seen flag set.
  24. #
  25. #
  26. # Pump a STATUS command into the PREAUTH imap binary and parse for the return value.
  27. #
  28. # Examples:
  29. #
  30. # ./imap_status.sh inbox UNSEEN
  31. # ./imap_status.sh inbox MESSAGES
  32. #
  33.  
  34. PREAUTH_SERVER="MAIL=maildir:~/.maildir /usr/libexec/dovecot/imap 2>&1"
  35.  
  36. if [ "$#" != "2" ]; then
  37. echo "usage: imap_status.sh <mailbox> <item>"
  38. exit 2
  39. fi
  40.  
  41. echo "a1 status $1 ($2)" | eval $PREAUTH_SERVER | grep '^* STATUS' \
  42. | sed -e "s/\(.*\) ($2 \(.*\))/\2/" | tr -d '\015'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement