How to edit/override virtual_aliases_nostar

rclemings

Well-Known Member
Nov 5, 2007
51
5
58
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:

[email protected]
virtual_aliases_nostar via /etc/userdomains
[email protected]
[email protected]
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{[email protected]$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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
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?
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.