In article <000101c0df38$7ccac500$[EMAIL PROTECTED]> you wrote:
> Greetings,
>    We've got a POP3 setup working just fine, but there is a desire to
> add IMAP servers so that web mail might be added also.  The problem
> I see is that users will be making misc new subdir's in their Maildir
> on the same level as new and cur, such as stuff_from_joe, spam, whatever.
> 
> So I've been asked to munge up qmail-pop3d so it can pull mail from
> all these potential directories, not just new and cur, just in case that
> user
> decides to use our POP3 server at a later date to check mail.
> 
> Think this would be a major undertaking?
> 
> Snooping around qmail-pop3d.c I see a call to maildir_scan which seems
> to look in new and cur for mail during its getlist process.  Perhaps I could
> have that code first do a lookup for other directories besides new and cur
> (and tmp) and loop through that list of directories looking for mail to give
> to getlist.
> 
> Am I just making a mess of things here?  Is there an easier way to do this?
> 
> Thanks for any thoughts, good or bad.

The difficulty is to not cause problems for the user, e.g. say they use IMAP
normally then use POP3 once (for some reason) - you don't want all their
carefully stored mails in each IMAP folder getting deleted (do you?).

Thus, the simplest way to "fix" this is to:

Write a program, perl / shell / whatever which will be run after the
checkpoppassword, but before qmail-pop3d which uses the env variables supplied
by checkpoppasswd. 
The program will ensure its UID is the same as $USER's and change to $HOME.
It will read in all files/dirs in $HOME, then loop through each, skipping
new, cur and tmp.  For every other folder, read in the list of files
then for each file symlink it to new.

That way, when the user POP3's they get access to all their mails in all
IMAP folders, but when pop3d deletes the mails, it is deleting the symlinks,
not the real emails.

Very crudely something like this will work:

#!/usr/bin/perl

$HOME = $ENV{'HOME'};
$USER = $ENV{'USER'};
$MAILDIR = "$HOME/Maildir";

chdir($MAILDIR);
$dirs = `ls`;
@dirs = split(/\n/, $dirs);
foreach $dir (@dirs) {
  chomp($dir);
  if (-d "$MAILDIR/$dir") {
    next if ($dir =~ /^(new|cur|tmp)$/ );       #Skip new/cur/tmp dirs
    $files = `ls $dir`;
    @files = split(/\n/, $files);
    foreach $file (@files) {
      chomp($file);
      symlink("$MAILDIR/$dir/$file", "$MAILDIR/new/$file");
    }
  }
}

exec("/var/qmail/bin/qmail-pop3d");
exit(0); #redundant


I have not tested this - simply typed into this mail - and I've been
lazy with the system `ls` calls - you really should use opendir/readdir
to do this properly.

Paul.
-- 
| Paul Gregg                    |T: +44 (0) 28 90424190
| Technical Director            |F: +44 (0) 28 90424709
| The Internet Business Ltd     |W: http://www.tibus.com
| Holywood House, Innis Court   |E: [EMAIL PROTECTED]
| Holywood, Co Down, BT18 9HF   |P: [EMAIL PROTECTED]

Reply via email to