Re: [exim] One Smart Host for certain domain

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Effendy Abdullah
Dátum:  
Címzett: Exim-users
Tárgy: Re: [exim] One Smart Host for certain domain
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.