Mailing List Archive

One Smart Host for certain domain
Hi,

How do I route to one Smart Host for certain domain and all other domain route to another Smart Host. Using WHM/cPanel with Exim.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: One Smart Host for certain domain [ In reply to ]
On 27/08/2021 14:35, Effendy Abdullah via Exim-users wrote:
> How do I route to one Smart Host for certain domain and all other domain route to another Smart Host. Using WHM/cPanel with Exim.
>

That depends on the facilities that cPanel offers, since you're not
using Exim directly.
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: One Smart Host for certain domain [ In reply to ]
Am 27.08.21 um 15:35 schrieb Effendy Abdullah via Exim-users:
> Hi,
>
> How do I route to one Smart Host for certain domain and all other domain route to another Smart Host. Using WHM/cPanel with Exim.
The answere you seek is in the default config:

# Alternatively, comment out the above router and uncomment this one to
# route all mail to a smarthost instead of sending it directly to the
# intended recipients. If your smarthost requires authentication, change
# 'remote_smtp' to 'remote_msa' and set up the 'client_auth' authenticator
# later in this file. You might need to change the port number in the
# remote_msa transport.
#

begin routers

smarthost:
  driver = manualroute
  domains = ! +local_domains
  condition = ${if eq{"domainname.target"}{${domain}}}
  transport = remote_smtp
  route_data = smarthost.myisp.net
  no_more

...{repeat as often as needed}...

dnslookup:
  driver = dnslookup
  domains = ! +local_domains
...

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: One Smart Host for certain domain [ In reply to ]
On 2021-08-31 19:52, Cyborg wrote:
> Am 27.08.21 um 15:35 schrieb Effendy Abdullah via Exim-users:
> > Hi,
> >
> > How do I route to one Smart Host for certain domain and all other domain route to another Smart Host. Using WHM/cPanel with Exim.
> The answere you seek is in the default config:
>
> # Alternatively, comment out the above router and uncomment this one to
> # route all mail to a smarthost instead of sending it directly to the
> # intended recipients. If your smarthost requires authentication, change
> # 'remote_smtp' to 'remote_msa' and set up the 'client_auth' authenticator
> # later in this file. You might need to change the port number in the
> # remote_msa transport.
> #
>
> begin routers
>
> smarthost:
> driver = manualroute
> domains = ! +local_domains
> condition = ${if eq{"domainname.target"}{${domain}}}
> transport = remote_smtp
> route_data = smarthost.myisp.net
> no_more
>
> ...{repeat as often as needed}...
>
> dnslookup:
> driver = dnslookup
> domains = ! +local_domains
> ...
>
>

I think I didn't make myself clear.
I'm using MailGun as a smartest with one "default" credentials, with about 80 domains. Some of the domain will be using their own login credentials for MailGun.

So my current Exim config in WHM is as follows:

#Section: AUTH
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}: ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}

#Section: ROUTERSTART
mailgun:
driver = manualroute
domains = ! +local_domains
transport = mailgun_transport
route_list = "* smtp.mailgun.org::587 byname"
host_find_failed = defer
no_more

#Section: TRANSPORTSTART
mailgun_transport:
driver = smtp
hosts = smtp.mailgun.org
hosts_require_auth = smtp.mailgun.org
hosts_require_tls = smtp.mailgun.org

#My /etc/exim_smarhost
domain1.com: domain=domain1.com user=MAILGUN_smtp_user1 pass=MAILGUN_api_password1
domain2.com: domain=domain2.com user=MAILGUN_smtp_user2 pass=MAILGUN_api_password2


I just need the AUTH section to get users on the list /etc/exim_smarhost while those not on the list will have a default password. I'm trying not to list all 80+ domains on the list.

I've tried:
#Section: AUTH
mailgun_login:
driver = plaintext
public_name = LOGIN
hide client_send = : ${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/exim_smarthosts}{$value}}}{}{DEFAULT_MAILGUN_SMTP_LOGIN : DEFAULT_MAILGUN_SMTP_PASS}{${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}fail}}} : ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}fail}}}}}

In Exim command line it works, but when I try sending an email I get an error. Most likely some syntax issues with regards to the colon ' : ', still can't figure it out. The ' : ' is recognized as the start of a new string so it expects a ' } ' to close the string. Adding double colon ' :: ' will result in Auth failure.






--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: One Smart Host for certain domain [ In reply to ]
On 2021-08-31, Effendy Abdullah via Exim-users <exim-users@exim.org> wrote:
> On 2021-08-31 19:52, Cyborg wrote:
>> Am 27.08.21 um 15:35 schrieb Effendy Abdullah via Exim-users:
>> > Hi,
>> >
>> > How do I route to one Smart Host for certain domain and all other domain route to another Smart Host. Using WHM/cPanel with Exim.
>
> I think I didn't make myself clear.
> I'm using MailGun as a smartest with one "default" credentials, with about 80 domains. Some of the domain will be using their own login credentials for MailGun.
>
> So my current Exim config in WHM is as follows:
>
> #Section: AUTH
> mailgun_login:
> driver = plaintext
> public_name = LOGIN
> hide client_send = : ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}: ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}

A:
change lsearch to nwildlsearch
add a * entry at the end of the /etc/exim_smarthosts file. that entry has the default credentials

or

B:
use the not-found branch of "lsearch" or "extract" to get the default
credentials.

which means code like:

hide client_send = : \
${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}{DEFAULTUSER}}}}:\
${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}{$value}{DEFAULRPASS}}}}

or

hide client_send = : \
${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}{$value}{DEFAULTUSER}}:\
${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}{$value}{DEFAULRPASS}}



--
Jasen.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: One Smart Host for certain domain [ In reply to ]
On 2021-09-01 01:33, Jasen Betts wrote:
> On 2021-08-31, Effendy Abdullah via Exim-users <exim-users@???> wrote:
> > On 2021-08-31 19:52, Cyborg wrote:
> >> Am 27.08.21 um 15:35 schrieb Effendy Abdullah via Exim-users:
> >> > Hi,
> >> >
> >> > How do I route to one Smart Host for certain domain and all other domain route to another Smart Host. Using WHM/cPanel with Exim.
> >
> > I think I didn't make myself clear.
> > I'm using MailGun as a smartest with one "default" credentials, with about 80 domains. Some of the domain will be using their own login credentials for MailGun.
> >
> > So my current Exim config in WHM is as follows:
> >
> > #Section: AUTH
> > mailgun_login:
> > driver = plaintext
> > public_name = LOGIN
> > hide client_send = : ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}: ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}
>
> A:
> change lsearch to nwildlsearch
> add a * entry at the end of the /etc/exim_smarthosts file. that entry has the default credentials
>
> or
>
>
>
>
>
>
>
>
> --
> Jasen.
>
>

Wow thank you so much! Everyone here is awesome...
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/