Mail filtering for all user boxes

I wrote a mail filtering rule using a .forward file, but it only works for the local system user and one mailbox. How to make the filtering rule work for all mailboxes of one HestiaCP user? Please help, I’m tired of looking for a solution.

Apparently I figured it out. It is necessary to look towards check_local_user or local_user. Now I will try. And yes, thanks for such active help friends ))

I feel guilty for having read your post and not helping.

Sorry if my lack of knowledge made you feel helpless.

If I had posted, I would have had to try to figure out your problem on my own and I would have felt helpless too. Maybe I should have tried and then asked again here and start a recursive circle of people trying to solve your problem and coming back here to ask for help.

Thank you for the answer. Now I’m trying to achieve the desired result through experiments, but so far without success. I think if someone faced such a problem, they wrote possible solutions. Apparently I’m the only one)) The essence is the same, how to make the filter work for the HestiaCP user …

Found how to specify an explicit path to the user’s .forward folder. So:

userforward:
  driver = redirect
  check_local_user
  #current_directory = /
  #check_owner
  #file = $home/mail/.forward
  #require_files = $home/admin/.forward
  file = ${expand:${lookup{$local_part}lsearch{/home/admin/mail/domain.com/$local_part/.forward}}}
  require_files = ${local_part}:+${home}/.forward
  domains = +local_domains
  allow_filter
  no_verify
  no_expn
  check_ancestor
  forbid_smtp_code = true
  directory_transport = address_directory
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply

Now got this:

2023-05-16 14:49:59 1pyrJb-002Hkz-8D Tainted filename for search: ‘/home/admin/mail/domain.com/min/.forward’
2023-05-16 14:49:59 1pyrJb-002Hkz-8D == [email protected] R=userforward defer (-1): failed to expand “${expand:${lookup{$local_part}lsearch{/home/admin/mail/domain.com/$local_part/.forward}}}”: NULL

Now it looks like it’s a permissions issue.

Then change to 777 and if it works it’s permissions and then adjust it. In that case it could be group ownership.

Thanks jlguerrero. I tried to do so. So far it hasn’t helped. I’m looking for a solution further. If I find something I’ll let you know.

It is a pain.

Probally the easiest method is set up Dovecot sieve + an general sieve rule…

1 Like