From: /dev/rob0 on
On Thu, Mar 25, 2010 at 05:05:47PM +0530, Chaminda Indrajith wrote:
> I need to put the SPAM mails into users' Junk Mail folder. How
> can we do it in Postfix?
>
> Mails are stored in Maildir format in the user's home directory.
> Junk mail folder is inside the Maildir as ".Junk". Amavisd-new
> tags the spam mails as "[SPAM]"

Amavisd-new can also use a recipient_delimiter and change the
localpart "user" to "user+spam". See amavisd-new documentation to
learn how to activate this feature.

Postfix local(8) can handle this differently by using a
~user/.forward+spam file.

Postfix virtual(8) can handle this differently by using a different
virtual_mailbox_maps result for user+spam(a)example.com .

References:
http://www.postfix.org/postconf.5.html#recipient_delimiter
http://www.postfix.org/local.8.html
http://www.postfix.org/aliases.5.html
http://www.postfix.org/virtual.8.html
http://www.postfix.org/postconf.5.html#virtual_mailbox_maps
--
Offlist mail to this address is discarded unless
"/dev/rob0" or "not-spam" is in Subject: header

From: /dev/rob0 on
On Fri, Mar 26, 2010 at 08:26:33AM +1100, Voytek Eymont wrote:
> so, if I was to create a mail user 'voytek+spam' in the database,
> '+spam' mail would end up in voytek+spam mail user maildir ?

The user for virtual(8) must be the full address:
voytek(a)example.com example.com/voytek/maildir/
voytek+spam(a)example.com example.com/voytek/maildir/.spam/
other(a)example.com example.com/other/maildir/
other+spam(a)example.com example.com/other/maildir/.spam/

The concept of "user" is blurred here. To virtual, these are like
different users. But to your IMAPd, ideally, you are simply
delivering mail to another folder owned by that virtual user.

There might be SQL tricks you can use to get the +spam queries to
return the spam mailfolder paths, too. That's beyond the scope of
this list, and beyond my very modest SQL literacy level. But DB
storage is cheap, and it's easy to script something like this to
populate your database for all existing users.

> is that what I would need to as as 'next step' within above setup ?
>
> how to make that as a spam subfolder for 'voytek' ?
>
> is that something like... symlinking ?? voytek+spam mail user to
> voytek's spam folder ??
>
> sorry for dumb question, pls speak slowly...

No problem, but at this point you should look at your IMAP server
documentation on how to deliver to a virtual user's subfolder. The
example above, I think, will work with Dovecot, but it assumes that
voytek(a)example.com has $virtual_mailbox_base/example.com/voytek/ as
HOME, and $HOME/maildir/ as top-level folder.
--
Offlist mail to this address is discarded unless
"/dev/rob0" or "not-spam" is in Subject: header

From: "Chaminda Indrajith" on
Hi rob0,

~user/.forward+spam would be a good solution for me since my users are
system users.

Could you give me an example for the following? I can configure
amavisd-new to do + address extension.

## Deliver user+spam(a)example.com mails to /home/user/Maildir/.Junk

..Junk is also in Maildir format.

Appreciate your help in this regard.

Thanks
Indrajith




On Thu, 25 Mar 2010 10:29:43 -0500
/dev/rob0 <rob0(a)gmx.co.uk> wrote:
> On Thu, Mar 25, 2010 at 05:05:47PM +0530, Chaminda Indrajith wrote:
>> I need to put the SPAM mails into users' Junk Mail folder. How
>> can we do it in Postfix?
>>
>> Mails are stored in Maildir format in the user's home directory.
>> Junk mail folder is inside the Maildir as ".Junk". Amavisd-new
>> tags the spam mails as "[SPAM]"
>
> Amavisd-new can also use a recipient_delimiter and change the
> localpart "user" to "user+spam". See amavisd-new documentation to
> learn how to activate this feature.
>
> Postfix local(8) can handle this differently by using a
> ~user/.forward+spam file.
>
> Postfix virtual(8) can handle this differently by using a different
> virtual_mailbox_maps result for user+spam(a)example.com .
>
> References:
> http://www.postfix.org/postconf.5.html#recipient_delimiter
> http://www.postfix.org/local.8.html
> http://www.postfix.org/aliases.5.html
> http://www.postfix.org/virtual.8.html
> http://www.postfix.org/postconf.5.html#virtual_mailbox_maps
> --
> Offlist mail to this address is discarded unless
> "/dev/rob0" or "not-spam" is in Subject: header

From: "Voytek Eymont" on

On Fri, March 26, 2010 9:51 am, /dev/rob0 wrote:
> On Fri, Mar 26, 2010 at 08:26:33AM +1100, Voytek Eymont wrote:
>
>> so, if I was to create a mail user 'voytek+spam' in the database,
>> '+spam' mail would end up in voytek+spam mail user maildir ?

> The user for virtual(8) must be the full address:
> voytek(a)example.com example.com/voytek/maildir/ voytek+spam(a)example.com
> example.com/voytek/maildir/.spam/ other(a)example.com

> The concept of "user" is blurred here. To virtual, these are like
> different users. But to your IMAPd, ideally, you are simply delivering mail
> to another folder owned by that virtual user.
>
> There might be SQL tricks you can use to get the +spam queries to
> return the spam mailfolder paths, too. That's beyond the scope of this
> list, and beyond my very modest SQL literacy level. But DB storage is
> cheap, and it's easy to script something like this to populate your
> database for all existing users.

rob0,

many thanks for explanations !! this now seems simpler than I feared!!

I've looked at this in the past on and off, even installed maildrop, but
the virtual delivery agent seem a simpler way

I've created a new mailbox as for 'voytek+spam', edited relevant path,
and, bingo:

voytek's 'spam' IMAP folder gets the '+spam'

thanks again!!

Mar 26 17:29:18 bilby postfix/lmtp[5924]: 2F4E3B44906:
to=<voytek+spam(a)sbt.net.au>, relay=127.0.0.1[127.0.0.1]:10024, delay=6.1,
delays=2.2/0.01/0.01/3.8, dsn=2.0.0, status=sent (250 2.0.0 Ok,
id=02838-15, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as
AFFACB448FD)

Mar 26 17:30:06 bilby postfix/virtual[6058]: B8F59B44909:
to=<voytek+spam(a)sbt.net.au>, relay=virtual, delay=936,
delays=936/0.01/0/0.05, dsn=2.0.0, status=sent (delivered to maildir)


I guess I can start setting to deliver individual spam to individual users
with virtual and plus subaddressing

--
Voytek

From: /dev/rob0 on
Please don't top-post replies. Also note, I set Reply-To: to keep
discussions on list. I do not want a CC:.

On Fri, Mar 26, 2010 at 06:03:47AM +0530, Chaminda Indrajith wrote:
> ~user/.forward+spam would be a good solution for me since my
> users are system users.
>
> Could you give me an example for the following? I can configure
> amavisd-new to do + address extension.
>
> ## Deliver user+spam(a)example.com mails to /home/user/Maildir/.Junk
>
> .Junk is also in Maildir format.

Sure. While I would prefer to see you try it yourself, this will
complete the thread for the archives. I gave Voytek examples for
virtual(8), so here's yours:

user(a)server:~$ echo '/home/user/Maildir/.Junk/' > ~/.forward+spam

The file should be owned and readable by this user. Likewise,
/home/user/Maildir/.Junk/ needs rwx permissions for this user. The
trailing slash on the directory name is what tells local(8) that
you're using a maildir.

Most OS's that I have experience with have a /etc/skel directory
which is used to populate the HOME for a new user. You can't use
variables like $USER in a .forward file, and you obviously cannot
have an absolute path in a skel file, but this worked for me:

root(a)server:~# echo '~/Maildir/.Junk/' > /etc/skel/.forward+spam

Quoting is necessary there to prevent expansion of "~". Consult
your OS documentation for information on new user creation and
default files.

> >References:
> > http://www.postfix.org/postconf.5.html#recipient_delimiter
> > http://www.postfix.org/local.8.html
> > http://www.postfix.org/aliases.5.html
--
Offlist mail to this address is discarded unless
"/dev/rob0" or "not-spam" is in Subject: header