Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

script for migrating from UW-IMAP to Dovecot [PATCHED]


# A script for migrating from UW-IMAP to Dovecot
# By Andrew Ziem
# Copyright (c) 2007 Springs Rescue Mission.  All rights reserved.
# Moves UW-IMAP mboxes from two locations to ~/mail so that Dovecot
# can easily convert mboxes to Maildirs.  Mailboxes with whitespace
# should be handled properly, and IMAP subscriptions should be preserved.

# Edit the below variables



# to this function pass the user name
function move_mailboxlist
        if [ ! -d "$HOME_USERS/$1" ];
                echo "Error: $HOME_USERS/$1 does not exist"
                return 0

        # make ~/mail
        cd "$HOME_USERS/$1"
        mkdir mail
        chown "$1" mail

        # find each mbox and move it to ~/mail
        if [ ! -f ".mailboxlist" ];
                echo "Warning: .mailboxlist does not exist for $1"
                return 0
        # cat .mailboxlist | while read line; do mv "${line}" ./mail/; done
        cat .mailboxlist | tr '\n' '\0' | xargs -0 mv -t ./mail/

        # preserve subscriptions (to prevent manual resubscriptions)
        mkdir Maildir
        chown "$1" Maildir
        cp -a .mailboxlist Maildir/subscriptions

# move inbox from $MAIL_SPOOL to ~/mail/inbox
function move_inbox
        if [ ! -f "${MAIL_SPOOL}/$1" ];
                echo "Error: ${MAIL_SPOOL}/$1 does not exist"
                return 0
        cp "${MAIL_SPOOL}/$1" "${HOME_USERS}/$1/mail/inbox"
        chown "$1" "${HOME_USERS}/$1/mail/inbox"

if [ $# -eq 0 ];
        echo "First, did you edit the directory names in the script?"
        echo "Then, if you want to do a dry run, prefix mv and cp with echo."
        echo "Then, invoke $0 by passing one or more user names."

for user in $@
        echo "*** Processing user $user"
        move_mailboxlist $user
        move_inbox $user

Find flagged message subjects in maildir

Simple, perhaps slightly cryptic oneliner to get the subjects of all flagged messages in a Maildir. It assumes that 'F' is the flag for flagged messages (as it almost always is) and that your message files end with ":2,".

find ~/Maildir -type f -name "*:2,*F*" -exec egrep -h "^Subject:" "{}" ";" | cut -c 10-

Running Mutt w/Maildirs (not IMAP) on TxD servers via ssh

I modified Pteron's muttrc file to use my local Maildir rather than login via IMAP.

This is A) Faster/better since it cuts out the bother of an imap connection to localhost and accesses your mail directly, B) It actually works (the imap method always failed on a segfault for me at least), C) You gotta like not having to store your username/password in the clear since there's no imap login to perform D) More responsive than webmail for quick email checks, and works even when webmail doesn't.

To use, change the realname line and save with filename ".muttrc"; upload this to your home directory, then login via ssh and type "mutt".

# For TextDrive accounts (running mutt on the server)

set mbox_type=Maildir
set folder="~/Maildir/"
set spoolfile="~/Maildir/"
set mask="!^\\.[^.]"
set record="+.Sent"
set postponed="+.Drafts"

set realname="Yourname"

mailboxes `\
echo -n "+ "; \
for file in ~/Maildir/.*; do \
  box=$(basename $file); \
  if [ ! $box = '.' -a ! $box = '..' -a ! $box = '.customflags' \
      -a ! $box = '.subscriptions' ]; then \
    echo -n "+$box "; \
  fi; \

macro index c "?" "open a different folder"
macro pager c "?" "open a different folder"

set allow_8bit  # Don't do any Quoted-Printable encoding on 8-bit data!
set copy=yes    # Ask me if I want to save a copy of my outgoing messages.
set delete=yes
set noaskcc
set nomark_old
set reverse_alias
set reverse_name
set reply_to
set attribution="On %d, %n wrote:"
set envelope_from
set noconfirmappend
set print=ask-no
set print_cmd="echo Nix printi printi!"
set nosave_empty
set sort=threads
set read_inc=10
set write_inc=10
set noprompt_after
set status_format="%r %v [%?M?%M/?%m] %?n?%n new, ?%?p?%p postponed, ?%?t?%t +tagged, ?%?d?%d delet ed, ?(%h:%f) %?b?%b more to go.?%> %r"

#set alias_file="~/.aliases"
set quote_regexp="^([A-Za-z ]+>|[]>:|}-][]>:|}-]*)"
set include
set hdr_format="%4C %Z %{%b %d} %-15.15n (%4l) %s"
set nomove
set tilde
set noautoedit
set pager_context=1
set pager_stop
set pipe_decode
set postponed="+postponed"
set to_chars="b .c>"

set fast_reply

color header brightcyan black .
color header yellow black Subject:
color body brightyellow black [_a-z\.\$A-Z0-9-]+@[a-zA-Z0-9\./\-]+
color body yellow black (http|ftp)://[_a-zA-Z0-9\./~\-]+
color quoted green black
color signature brightblue black
color attachment yellow black
color tree red black
color indicator black cyan
color status yellow blue
color tilde blue black

bind pager 'w' previous-page
bind pager 'j' next-line
bind pager 'k' previous-line
bind index '#' tag-entry
bind index '{' previous-thread
bind index '}' next-thread

# Headers to ignore
ignore *
unignore date from to cc subject x-mailer resent-from reply-to
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed