June 30, 2020 6:34 AM, "Unicorn" <unic...@disroot.org> wrote:

> Hello everyone,
> 

Hello,


> I am a newbie to mail in general and opensmtpd in particular and I am
> currently trying to figure out how to sort mail to various subdirs of
> the maildir based on the address that an email was sent to.
> 
> So basically, this is my intended setup:
> 
> 1. Somebody sends email to b...@mydomain.org
> 2. "blog" is an alias that forwards to a real "admin" account
> 3. In the maildir of "admin", the email goes to a subdir called "blog"
> 
> I looked through the the smtpd.conf(5) manpage and found the "match
> action" directive, my thought was something like this:
> 
> action "sort_to_folder" maildir "~/Maildir/.Blog" alias <aliases>
> match for rcpt-to "b...@mydomain.org" action "sort_to_folder"
> 
> But I found that with this setup, junk will not get removed, and if I
> add "junk" after the custom directory, I believe it will end up in
> "~/Maildir/.Blog/.Junk" instead of "~/Maildir/.Junk".
> 
> Is there a more elegant/smart solution that I am missing? I would be
> happy to learn from you. :)
> 

Yeah this won't work like that:

The maildir mda takes the maildir root directory as a parameter, it'll
expect .Junk to be relative.

You have two methods to achieve what you want:

1- use a smarter mda, such as `fdm`, which allows you to specify where mails are
   supposed to be delivrered based on rules. in this case, you would simply have
   a rule that recipient address blog@ should land in .Blog

2- alias blog to admin+blog instead of admin, this way when smtpd extracts email
   extension, it will check if a .blog folder exists and deliver there if exists
   but this is more limited that a real classification.

Gilles

Reply via email to