SOLVED EXIM Outgoing IPs Per Account?

Rogerio

Well-Known Member
Sep 26, 2016
78
15
8
Sao Paulo, Brazil
cPanel Access Level
Root Administrator
Hello,

I'm trying to setup my new server with 2 IPs to send emails using account's IP in SMTP and Exim banner. I read How to Configure the Exim Outgoing IP Address - cPanel Knowledge Base - cPanel Documentation but I cannot accomplish what I need. Please, can you help me?

Send mail from the account’s IP address is enabled.

Scenario:
- server's hostname: first.mydomain.com
- first IP: 1.1.1.1 PTR first.mydomain.com
- second IP: 2.2.2.2 PTR second.mydomain.com

Reason: accounts on 1.1.1.1 will not have IMAP access (basic plan). Accounts on 2.2.2.2 will (pro plan). IMAP ports blocked on iptables (and like --dport 143 -d 2.2.2.2 -j ACCEPT).

I don't want users know the server is the same. Means, everything in basic plan will refer to 1.1.1.1 and first.mydomain.com, and everything in pro plan 2.2.2.2 and second.mydomain.com. Including SMTP outgoing IP, SMTP HELO and SMTP/POP/IMAP banner (if possible).

If one user realize that he can "telnet 2.2.2.2 587" and see "first.mydomain.com" as hostname will see that it's the same server. That's not my main problem, but if possible is highly appreciate. My main problem is outgoing SMTP IP.

I've created 2 DNS zones (on WHM), for each subdomain,
first.mydomain.com IN A 1.1.1.1
first.mydomain.com. IN PTR first.mydomain.com.
----
second.mydomain.com IN A 2.2.2.2
second.mydomain.com. IN PTR second.mydomain.com.

Exim is always using the correct IP to outgoing connection, but not considering the DNS zones.

So, from where Exim exaclty get the hostname to use as SMTP HELO?

Any help is appreciated.
 

24x7server

Well-Known Member
Apr 17, 2013
1,911
96
78
India
cPanel Access Level
Root Administrator
Twitter
Hi,

You need to enable /etc/mailip in the exim configuration first, so the exim will look for this first before processing the mail.
Secondly you need to add
domain: IP address, so domain will from that IP only.
 

Rogerio

Well-Known Member
Sep 26, 2016
78
15
8
Sao Paulo, Brazil
cPanel Access Level
Root Administrator
Ok, so, for my case, Send mail from the account’s IP address won't work?

Using /etc/mailip and /etc/mailhelo works fine.

And for SMTP banner? Any way to show the rDNS instead of server's hostname?
 

Rogerio

Well-Known Member
Sep 26, 2016
78
15
8
Sao Paulo, Brazil
cPanel Access Level
Root Administrator
Ah, I found a solution, editing using Exim Advanced Editor:

1) click "Add additional configuration setting"
2) insert "smtp_active_hostname"
3) value "${if exists {/etc/mail_ptr}{${lookup{$interface_address}lsearch{/etc/mail_ptr} {$value}{$primary_hostname}}}{$primary_hostname}}"
4) edit "smtp_banner"
5) in the beginning, change "${primary_hostname}" to "${smtp_active_hostname}"

Then...

6) create file /etc/mail_ptr like:

1.1.1.1: first.mydomain.com
2.2.2.2: second.mydomain.com

Done. When I "telnet 2.2.2.2 587" I can see:

220-second.mydomain.com ESMTP Exim 4.91 #1 Thu, 20 Sep 2018 13:34:32 -0300
220- We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.

POP/IMAP don't have hostname banners. My mistake in the first message.
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463
Hello @Rogerio,

I'm happy to see you were able to solve the issue. Thank you for sharing the outcome.
 
  • Like
Reactions: Rogerio