How to change exim to relay from subdomain instead of hostname
hi Team,
Websites on server cannot relay to GMail addresses only at present.
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:
XXXXXXX@gmail.com
host gmail-smtp-in.l.google.com [172.217.194.27] SMTP error from remote mail server after end of data:
550-5.7.25 [45.XX.XX.XX] The IP address sending this message does not have a
550-5.7.25 PTR record setup, or the corresponding forward DNS entry does not
550-5.7.25 point to the sending IP. As a policy, Gmail does not accept messages
550-5.7.25 from IPs with missing PTR records. For more information, go to
550-5.7.25 https://support.google.com/mail/answer/81126#ip-practices
550-5.7.25 To learn more about Gmail's sender policy, go to
550 5.7.25 https://support.google.com/mail/answer/81126. i7-20020a170902c94700b001e7b7c93013si9333979pla.627
The PTR record is setup for whm.mydomain.com and is correct IP address. However the domain name is whm.mydomain.com for webserver and it is proxied behind CloudFlare. Thus when you do a lookup for A record it shows the CF Proxy ip addresses. Thus Google is failing the emails and not accepting them.
The PTR record appears to be correct:
dig -x 45.XX.XX.XX +short
whm.mydomain.com
However, that domain name does not also resolve to the IP, which is the second half of the error.
dig whm.mydomain.com +short
172.67.193.111
104.21.82.20
I cannot remove the "CF" proxy as the Data Centre firewall is set to only receive http and https traffic from CloudFlare IPS only. thus if I remove proxy the SSL cert renewal process will not work for cPanel services for the server .
I would like to know if anyone can advise a way I can get EXIM to relay email from a different hostname . For example whm-mail.mydomain.com or even subdomain smtp.whm.mydomain.com and thus I could set the PTR for server to this subdomain and also an A record to this same IP address and would not impact server configuration or operations of SSL renewals etc.
Any help would be greatly appreciated.
-
I think I found the solution here:
1. modify /etc/mailhelo
smtp.whm.mydomain.com # added this to file and saved
2. Then updated and amended Home / Service Configuration / Exim Configuration Manager
Reference /etc/mailhelo for custom outgoing SMTP HELO [?]
Send HELO based on the domain name in /etc/mailheloI then turned this on.
And saved and restarted. Pending for time to propagate and will test but any feedback from anyone would be appreciated.
I also amended the PTR to be smtp.whm.mydomain.com via the hosting control panel as well. Will wait for propagation and do tests tomorrow.
1 -
to update this I believe I may have the answer but want to confirm if this is correct process and will not be overwritten in updates etc.
I want to amend /etc/exim.conf
# primary_hostname =
Un remark the above and enter in
primary_hostname = smtp.whm.mydomain.com
And then make A record not proxied for smtp.whm.mydomain.com so it will reveal the correct IP ADdress in reverse lookup.However as per here: it says you must use the Exim Advanced editior Exim Configuration Manager | cPanel & WHM Documentation and it will create /etc/exim.conf.local file. However I cannot see in the Advanced editor where it allows to amend "primary hostname"
Can I just make the /etc/exim.conf.local file with touch and then just add:primary_hostname = smtp.whm.mydomain.com
And save file. Would that work?
Also thanks to Shane from Vultr for his support and assistance to date has been very helpful.
0 -
To change Exim to relay from a subdomain instead of the hostname, you'll need to adjust the configuration settings in Exim. Here's a step-by-step guide:
-
Open the Exim configuration file: Locate the Exim configuration file on your system. Typically, this file is named
exim.conf
orexim4.conf
, and it's usually found in the/etc/exim
directory. -
Find the
router
section: In the configuration file, search for the section that defines the routers. This section contains rules that determine how Exim routes messages. -
Modify the router settings: Look for the router responsible for handling outgoing mail, often named something like
dnslookup
,smarthost
, orremote_smtp
. Within this router definition, you'll find settings related to relaying. -
Update the relay configuration: Locate the setting that specifies the hostname used for relaying. This setting might be named
smarthost
,hosts_try_auth
, or similar. Change the hostname specified here to your desired subdomain. -
Save the changes: After making the necessary adjustments, save the configuration file.
-
Restart Exim: To apply the changes, restart the Exim service using the appropriate command for your operating system. This might be something like
service exim restart
orsystemctl restart exim
. -
Test the configuration: Send a test email from your system to ensure that Exim is relaying outgoing mail through the specified subdomain.
By following these steps, you can configure Exim to relay outgoing mail through a subdomain instead of the hostname.
And yes do remember to carefully review the changes to ensure they align with your requirements and existing configuration.
0 -
-
hi Digital Pinacle thanks for the assistance. However as per https://docs.cpanel.net/whm/service-configuration/exim-configuration-manager/?_ga=2.2318130.38152556.1714346871-834511574.1711492903 They advise not to make changes to /etc/exim.conf as they will be lost on updates etc. Whilst the above most likely applies to exim on a standard linux server I believe exim on cPanel/WHM server is slightly different. I need to find out how to find the relevant action in WHM.
I will see if I can find the above solution to implement like for like in WHM.
0 -
hi I found the solution and resolves all issues.
amend /etc/exim.conf
primary_hostname = smtp.whm.mydomain.com
This resolves all issues and WORKS perfectly and problem solved. ONLY issue I still now have is to ensure this is not lost after update and overwritten. Not sure how to ensure this change is "permanent"
Any time make "any change to EXIM" config in WHM this is lost and reverts back to:
split_spool_directory = yes
smtp_connect_backlog = 50
smtp_accept_max = 100# primary_hostname =
# Specify the domain you want to be added to all unqualified addresses
# here. An unqualified address is one that does not contain an "@" character
# followed by a domain. For example, "caesar@rome.ex" is a fully qualified
# address, but the string "caesar" (i.e. just a login name) is an unqualified
# email address. Unqualified addresses are accepted only from local callers by
# default. See the receiver_unqualified_{hosts,nets} options if you want
# to permit unqualified addresses from remote sources. If this option is
# not set, the primary_hostname value is used for qualification.# qualify_domain =
0 -
Hey there! It would be best to not include any public domain names or IP addresses in your post.
You'll want to use the Exim Configuration Manager through WHM to ensure these changes stay permanent: https://docs.cpanel.net/whm/service-configuration/exim-configuration-manager/
You can likely use the Advanced Editor mode to accomplish your changes.
0 -
cPRex thanks for response. I have edited all posts and changed to smtp.whm.mydomain.com . Apologise on that.
RE: You'll want to use the Exim Configuration Manager through WHM to ensure these changes stay permanent: https://docs.cpanel.net/whm/service-configuration/exim-configuration-manager/
I did already cover this in my initial post and aware of this. However can you please advise where in the Advanced editor you can clearly change the "primary_hostname" for EXIM. It does not offer anything regarding the primary_hostname that I could see.
0 -
What about the details mentioned here? This information is all still valid:
0 -
cPRex thanks for your reply. Can you please expand on this a little more still valid? It is from 4 years ago. I believe the way to resolve the issue is "amend" primary_hostname in exim. I have opened a ticket with cPanel support #95255429. They have advised this not possible at present and cannot be modified in the Advanced editor. See below from support team:
"Thank you for your patience. I've filed an internal case with our developers to add the ability to modify the primary_hostname value through the Exim Configuration Editor -> Advanced Editor. The case ID is CPANEL-44124"
The link you provided above mentions changing the qualify_domain . I do not believe this will resolve the issue.
The answer here is if anyone knows how to change /etc/exim.conf setting "primary_hostname" permanently. Ie so it is not lost after updates etc. Until a time it can be done via the Advanced Editor.0 -
Thanks for sharing that - if we checked out your system and confirmed it's not possible, that would be the final word.
0
Please sign in to leave a comment.
Comments
10 comments