Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to edit/override virtual_aliases_nostar

Discussion in 'E-mail Discussions' started by rclemings, Nov 22, 2016.

Tags:
  1. rclemings

    rclemings Active Member

    Joined:
    Nov 5, 2007
    Messages:
    29
    Likes Received:
    1
    Trophy Points:
    53
    I'm having some trouble with Exim that seems to be caused by the "unseen" directive in virtual_aliases_nostar director in the WHM Exim configuration, advanced editor.

    Background:

    I have a website on server2.example.com and a mail server on server1.example.com, and I want to use server1 as a smarthost for server2. So I added this to te "PREROUTERS" section in Exim, advanced editor, on server2 (adapted from Howto: redirect a copy of your emails to another server while saving it locally):

    smarthost:
    driver = manualroute
    domains = !+local_domains
    transport = remote_smtp
    headers_add = X-Custom-Forwarded: true
    condition = ${if match {$h_X-Custom-Forwarded:}{true}{false}{true}}
    route_data = "server1.example.com"

    That worked for all domains that existed on both servers.

    However, I have some domains that have their websites on server2, and only their DNS on server1. To get the smarthost to work for those domains, I had to add the domain name to /etc/localdomains and create a corresponding /etc/valiases file.

    After I did that, the mail sent from server2 was successfully delivered by server1, but the sender also got a failure notice.

    I entered the address into the Mail troubleshooter on server1 and got something like this:

    alias@domain.com
    virtual_aliases_nostar via /etc/userdomains
    forwardee@example.com
    alias@domain.com
    virtual_aliases via virtual_aliases router forced address failure

    In other words, the message was going first to virtual_aliases_nostar, then to virtual_aliases (apparently because of the "unseen" directive in virtual_aliases_nostar). It was delivered by virtual_aliases_nostar but then failed by virtual_aliases.

    Solution:

    It doesn't seem possible to edit virtual_aliases_nostar, so instead I added this to the "PREVALIASNOSTAR" section just above virtual_aliases_nostar:

    virtual_aliases_nostar1:
    driver = redirect
    allow_defer
    allow_fail
    require_files = "+/etc/valiases/$domain"
    address_data = ${lookup{$local_part@$domain}lsearch{/etc/valiases/$domain}}
    data = $address_data
    file_transport = address_file
    group = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
    user = "${lookup{$domain}lsearch* {/etc/userdomains}{$value}}"
    pipe_transport = ${if forall{/bin/cagefs_enter:/usr/sbin/cagefsctl}{exists{$item}}{cagefs_virtual_address_pipe}{${if match{${extract{6}{:}{${lookup passwd{${lookup{$domain}lsearch*{/etc/userdomains}{$value}}}{$value}}}}}{\N(jail|no)shell\N}{jailed_virtual_address_pipe}{virtual_address_pipe}}}}
    retry_use_local_part

    Basically, that's an exact copy of virtual_aliases_nostar, minus the "unseen" directive. It seems to fix my specific problem with no immediately visible side effects.

    Question:

    Is this going to cause other problems? And is there a better solution?

    FWIW, all of the addresses for these domains are forwarders in the /etc/valiases files; there are no actual mailboxes. Autoresponders still seem to work OK.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Those steps should work well based on the information you provided, and the changes should not be overwritten during updates.

    Let us know if you encounter any problems with this configuration in the future.

    Thank you.
     
Loading...

Share This Page