Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Aug 2001
    Posts
    89

    Default virtual user .forwar

    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

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    4

    Default

    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:

  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    7

    Default

    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 bob@domain.com'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?

  4. #4
    Member
    Join Date
    Jan 2004
    Posts
    7

    Default

    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 by cinergi; 01-31-2004 at 10:55 PM.

  5. #5
    Member
    Join Date
    Jan 2004
    Posts
    7

    Default

    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}}"

  6. #6
    Member
    Join Date
    Jul 2003
    Posts
    13

    Default

    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!

  7. #7
    Member
    Join Date
    Jan 2004
    Posts
    7

    Default

    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.

Similar Threads & Tags
Similar threads

  1. Warning: virtual() [function.virtual]: Unable to include 'cgi-bin/in.cgi'
    By its_joe in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-10-2008, 10:16 AM
  2. User unknown in virtual mailbox table
    By sparek-3 in forum E-mail Discussions
    Replies: 2
    Last Post: 08-13-2008, 06:24 PM
  3. Proftpd virtual user problems
    By p in forum cPanel and WHM Discussions
    Replies: 13
    Last Post: 10-26-2006, 12:27 PM
  4. Replies: 0
    Last Post: 09-13-2004, 06:21 AM
  5. User strays out of virtual domain causing Kaos!
    By ozzi4648 in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 01-17-2003, 08:17 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube