Change outbound domain for email with Exim

thealien

Member
Apr 1, 2014
6
0
51
cPanel Access Level
DataCenter Provider
I was trying to diagnose an email delivery issue with emails going from a customers hosted domain to gmail.com where the mail was going to spam. From the same server but a different domain the same mail was going to inbox. Even though gmail postmaster tools said the reputation was high there must be something else triggering this.

I used this post Forward certain domain emails to Smart Host to configure Exim to deliver this domain through AWS with the same result.

My next thought was "what if" I could change the outbound email coming from @domain1.com to @domain2.com using Exim so that the users didn't have to change anything. Once Gmail started to deliver domain1.com into the inbox again I could remove this and add domain2.com as an alias domain.

Can anyone give me some pointers on how to accomplish this using Exim ?

Perhaps a modified version of Exim: Change sender address when sending mails out of local network which would work on a cpanel server with multiple accounts and domains.
 

Volox

Member
Jun 11, 2017
18
2
3
San Diego
cPanel Access Level
Root Administrator
Are the two domains you have on the server using the same IP? Or are they using a dedicated IP?

Have you looked at the 'original message' raw format (menu item under the 3 dots in the upper right when viewing the message in gmail) to see if the email that is going to spam is failing DKIM or SPF ?
 

thealien

Member
Apr 1, 2014
6
0
51
cPanel Access Level
DataCenter Provider
I went through the headers in detail knowing how to read them. SPF/DKIM is good...passes on all counts.

Issue is not IP based. It's definitely domain based.
 

Volox

Member
Jun 11, 2017
18
2
3
San Diego
cPanel Access Level
Root Administrator
Is it safe to assume you've checked the domain for being listed on any blacklists?

Is the outbound helo name that is being used match the domain name of the sender? And does that server name have a valid SSL cert and is sending using TLS ?
 

thealien

Member
Apr 1, 2014
6
0
51
cPanel Access Level
DataCenter Provider
Yeah checked all the necessary. Emailed Gmail a bunch of times but they don't respond. At this point all I need to do is to try and use exim to re-write the outbound domain.

Perhaps I can use the AWS relay config I used and just setup another domain in there, but I'm sure Exim can do it...I just don't know how without breaking things.
 

Volox

Member
Jun 11, 2017
18
2
3
San Diego
cPanel Access Level
Root Administrator
What domain are you going to re-write the outbound domain to?

If all your headers look right and the delivery path is correct and spf and dkim is a pass, then maybe I'm missing where the problem is? I thought your problem was with getting the email to successfully deliver looking like it was coming from the domain of the sender; is that not the issue?
 

thealien

Member
Apr 1, 2014
6
0
51
cPanel Access Level
DataCenter Provider
I want to use Exim to rewrite the outbound domain of an email sent from this server.

If I add a domain forward I want to write the primary domain to the domain forward when an email is sent.

So if the domain of an email hosted on the server is @domain1.com I want to rewrite an outbound email when sent from @domain1.com to @domain2.com without the user having to do anything. This means I can change their outbound on the fly and since it’s a domain forward inbound will continue to work. Once I can get domain1.com out of the spam box I can remove the exim config and all continues to work.
 

Volox

Member
Jun 11, 2017
18
2
3
San Diego
cPanel Access Level
Root Administrator
I think what you would be looking for would be in the Exim Configuration -> Advanced Editor
Look for the section titled -> Section: REWRITE

I might be a little rusty on the pattern, but I think you're going to want something like:
*@domain1.com [email protected] Ffrs

If you use subdomains, you might have to also have
*@*.domain1.com [email protected] Ffrs

If anyone does silly things like putting an email address as [email protected], then you probably want to prefix the match string with ^(?i) so that it is case insensitive.

The flags at the end tell the rewrite which headers to apply to, so adjust according to what you are trying to do. You might also find that you need to use flag S depending on whether you have other processing that needs the domain rewritten beforehand.

Full docs are here: 31. Address rewriting

Best way to check without hosing your users while testing is to start with a specific match that you can test and then move to the generic. For example:
*[email protected] [email protected] Ffrs
 
  • Like
Reactions: cPanelMichael