Showing posts with label dovecot. Show all posts
Showing posts with label dovecot. Show all posts

Sunday, 11 March 2012

Two gotchas with Postfix, Dovecot, Amavis and Clamav on Debian Squeeze

1. The first problem was when this error appeared in /var/log/mail.log:


Mar 10 16:56:39 mailhost amavis[2877]: (02877-01) (!)ClamAV-clamd av-scanner FAILED: CODE(0x358cef8) unexpected , output="/var/lib/amavis/tmp/amavis-20120310T165639-02877/parts: lstat() failed: Permission denied. ERROR\n" at (eval 103) line 594.


The problem is that clamav requires access to files created by amavis. We fix this by putting amavis and clamav in each other's group.



usermod -a -G clamav amavis
usermod -a -G amavis clamav

Then restart amavis and clamav-daemon.

2. The second problem was when postfix could not authenticate incoming SMTP connections by chaining to dovecot's auth process, resulting in this message in /var/log/mail.log:

Mar 10 18:28:14 mailhost postfix/smtpd[7217]: warning: SASL: Connect to /var/run/dovecot/auth-client failed: No such file or directory

The problem is that postfix runs chrooted by default in Squeeze and this named pipe is outside of the chroot tree. To fix it we tell dovecot to use this path instead:



/var/spool/postfix/private/auth-client


Then in /etc/postfix/main.cf we specify the path to the named pipe with:



smtpd_sasl_path = private/auth-client


It's a path relative to $queue_directory which is /var/spool/postfix.

Friday, 2 September 2011

Importing a whole bunch of MH mail files into dovecot

I had some old MH mail that I recovered from backup that I wanted to import into my dovecot server. This is personal mail so I will only describe how to do it for my account. The MH file paths were of the form:


from/alice/1
from/alice/2
from/bob/1
from/carol/1


I wanted to import the alice mail into the logical dovecot mail folder Archives/from/alice and similarly for the others. (Archives is a Thunderbird standard.) In my dovecot setup however, the corresponding maildir directory is ~/Mail/.Archives.from.alice


First I shut down Thunderbird so that it wouldn't interfere during the second step later. This script does the job (backslash continuation inserted for clarity):


for d in from/*
do
  for f in $d/[0-9]*
  do
    /usr/lib/dovecot/deliver -s -m \
      Archives.${d/\//.} -p $f
  done
done


See the documentation of deliver for the meanings of the -s -m and -p options.


You can track the progress of the import by following the syslog file for mail. Any failed imports go into INBOX.


This second step is not required, but I am obsessive. I wanted each imported file to have the same timestamp as the old one. This script uses findup from the fslint toolkit to collect the duplicates (backslash continuation inserted for clarity):


/usr/local/src/fslint-2.42/fslint/findup \
  from ~/Mail/.Archives.*.* > /tmp/dups


This generates pairs of duplicates in /tmp/dups separated by a blank line. This script then applies the old timestamp to each new file.


while read a
do
  read b
  touch -r $a $b
  read c
done < /tmp/dups


I still have to figure out how to mark all the old mail read from the CLI. I just went into Thunderbird and marked each folder read. If you have a good solution, please do comment.