indiboi

Well-Known Member
Aug 14, 2001
89
0
306
The .forward file works fine for &real& aka localusers, however it isn't looked at for any of the secondary email accounts. There has to be a way to enable this functionality for all email accounts; however I just can't seem to figure out how to configure exim to look up the information required.

Has anyone done this, or does anyone know how I might be able to get it to work?

I'm attempting to setup tmda ( http://tmda.net ), it works fine for the primary account, but without .forward file parsing for secondary accounts it's null.

This is what I had patched together from the information I could find, it doesn't work though of course:

virtualuserforward:
driver = forwardfile
condition = &${lookup{$domain}lsearch* {/etc/userdomains}{$value}}&
file = ${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{${extract{5}{:}{$value}}/.forward}}
no_verify
no_expn
no_check_local_user
check_ancestor
filter
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply
suffix = -*
suffix_optional
 

veena

Registered
Dec 3, 2002
4
0
151
I too have the same problem, got it working for the default account, but the .forward and tmda are not processing the other mail accounts. Any ideas?

cPanel.net Support Ticket Number:
 

cinergi

Member
Jan 9, 2004
7
0
151
I first touched exim just a few days ago, so I'm sure this isn't a 'bug-free' fix to the problem. However, it's my bedtime :) I thought I'd share what I came up with so far. This config means you can create a .forward.virtualusername in the main account's home directory. There's one caveat - $home expansion inside the .forward.xxx will NOT work. I haven't yet figured out how to set it (I've tried the documented methods but they've not worked).

Add this to your exim config in the first box after the "DIRECTORS CONFIGURATION" (right before the "virtual_sa_user" director):

==============
virtual_userforward:
#!!# filter renamed allow_filter
driver = redirect
allow_filter
check_ancestor
user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
group = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
domains = lsearch;/etc/userdomains
no_expn
file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/.forward.${local_part}"
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply
no_verify
==============

Example:

domain = domain.com
user = mainuser (@domain.com)
domain home = /home/domain
virtualuser = bob (@domain.com)
==> Use /home/domain/.forward.bob

.forward will forward mainuser's mail.

Again, WARNING, this may break stuff. This has not been tested beyond the fact that it will forward [email protected]'s email. It may completely break the rest of the system :)

I would enjoy any feedback/notes/fixes on the above solution.. And perhaps we can get this integrated into the mainsteam cpanel code?
 

cinergi

Member
Jan 9, 2004
7
0
151
Here's a further revision which fixes the $home and relative path problem.

Box after "DIRECTORS CONFIGURATION"

Code:
virtual_userforward:
#!!# filter renamed allow_filter
  driver = redirect
  allow_filter
  check_ancestor
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  group = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  domains = lsearch;/etc/userdomains
  no_expn
  file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/.forward.${local_part}"
  file_transport = virtual_address_file
  pipe_transport = virtual_address_pipe
  reply_transport = address_reply
  no_verify
Box right before "RETRY CONFIGURATION"

Code:
virtual_address_file:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/mail/${domain}/${local_part}/$address_file"
  group = mail
  mode = 0660
  quota = "${if exists{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/etc/${domain}/quota} {${lookup{$local_part}lsearch*{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/etc/${domain}/quota}{$value}}} {}}"
  return_path_add
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
Make sure you un-wrap any lines from your cut-n-paste here.

I'll continue testing and let you know if I revise further...

[edit]
Note that this skips all spam checking. That's my next problem to tackle ....
[/edit]
 
Last edited:

cinergi

Member
Jan 9, 2004
7
0
151
I must be talking to a wall :) Anyway here's the latest mods which include spamassassin.. Same two boxes. Box 1:

Code:
virtual_sa_userforward:
#!!# filter renamed allow_filter
  driver = redirect
  allow_filter
  condition = "${perl{checksa_deliver}{$domain}{$local_part}{$received_protocol}}"
  check_ancestor
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  group = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  domains = lsearch;/etc/userdomains
  no_expn
  file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/.forward.${local_part}"
  file_transport = virtual_sa_address_file
  pipe_transport = virtual_sa_address_pipe
  reply_transport = address_reply
  no_verify

virtual_userforward:
  driver = redirect
  allow_filter
  check_ancestor
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  group = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  domains = lsearch;/etc/userdomains
  no_expn
  file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/.forward.${local_part}"
  file_transport = virtual_address_file
  pipe_transport = virtual_address_pipe
  reply_transport = address_reply
  no_verify
Box 2:

Code:
virtual_sa_address_pipe:
  driver = pipe
  transport_filter = "/usr/bin/spamc"
  group = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
  return_output
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"

virtual_address_file:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/mail/${domain}/${local_part}/$address_file"
  group = mail
  mode = 0660
  quota = "${if exists{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/etc/${domain}/quota} {${lookup{$local_part}lsearch*{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/etc/${domain}/quota}{$value}}} {}}"
  return_path_add
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"

virtual_sa_address_file:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  transport_filter = "/usr/bin/spamc"
  file = "${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/mail/${domain}/${local_part}/$address_file"
  group = mail
  mode = 0660
  quota = "${if exists{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/etc/${domain}/quota} {${lookup{$local_part}lsearch*{${extract{5}{:}{${lookup{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}lsearch{/etc/passwd}{$value}}}}/etc/${domain}/quota}{$value}}} {}}"
  return_path_add
  user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
 

dougiamas

Member
Jul 15, 2003
13
0
151
Great work cinergi and thanks for posting your work here!

I'm just about to try your scripts (I love TMDA but had to drop it about 6 months ago when I moved from my custom qmail box to a Cpanel box).

Before I do this, how have they been going for you? Any new caveats or un-expected lost mail?

Cheers!
 

cinergi

Member
Jan 9, 2004
7
0
151
No problems as of yet. However I do now realize the filenaming convention (.forward.local-part-of-email-address) isn't such a good idea due to the ability of one account to have parked/addon/subdomains.. There may be a user@foo as well as a user@bar, in which case the .forward would act on the behalf of both users. Perhaps it would make sense to put a .forward in the mail/domainname/username/ directory instead. that's an easy enough change.
Note that filters defined in cpanel (aka /etc/vfilters) will be ignored if the user has a .forward file. All my mailing lists and spam-dumping via procmail has been working like a champ.