SOLVED Incoming email via relay server

eric_fri

Member
Mar 24, 2018
5
1
3
Canada
cPanel Access Level
DataCenter Provider
Hey everyone,

I've setup Proxmox Mail Gateway as a relay mail server with the intent of using it to filter both incoming and outgoing messages for spam. Currently, I have it working correctly with all my outgoing messages by using the smarthost setting in exim.

I can not get the incoming to work correctly. This is what I've tried:
- Set PMG to proxy via the "Relay Domains"
- Setup a transport for the same domain to the correct cPanel server (on its public IP)
- Changed the MX record of the domain I'm testing with to point at my PMG server
- Added the IP of my server into the /etc/alwaysrelay and /etc/trustedmailhosts files
- Disabled CXS
- Added the IP to the exim config via Trusted SMTP IP addresses
- Possibly more, I feel like I've tried so many things and none has worked.

The result I see with every config change is the message is bounced back to the sender email (a gmail account if that matters) immediately, then shortly after a second message.

The first message says:
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
The second message has a LOT of header info added indicating it's been received by both my mail gateway and cPanel, but cPanel has sent it back.

I haven't been able to find much in the logs that I've found helpful, but one message I see is
** [email protected]: Too many "Received" headers - suspected mail loop
Counting the duplicate subject lines it looks like the message is processed 10 times.

No matter what I've tried I don't receive the message in the final domain and it's bounced back.

Does anybody have any thoughts?

Cheers,
Eric
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463

eric_fri

Member
Mar 24, 2018
5
1
3
Canada
cPanel Access Level
DataCenter Provider
Thanks for the reply.

Both of those threads are dealing with outbound mail, which I already have working. I don't have inbound mail working correctly. When I setup my inbound mail to use my PMG it does arrive at cPanel, but cPanel sends it back out.

I believe the issue to be cPanel related and not PMG related, but I could be wrong.

This is what I see in the logs when cPanel receives the test message I send
Code:
SMTP connection from [167.***.***.200]:50148 (TCP/IP connection count = 1)

1ezbTk-0004Bh-KH <= [email protected] H=(mailgateway.mydomain.ca) [167.***.***.200]:50148 P=esmtp S=4043 [email protected]l.com T="test subject" for [email protected]
SMTP connection from (mailgateway.mydomain.ca) [167.***.***.200]:50148 closed by QUIT
cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1ezbTk-0004Bh-KH
1ezbTk-0004Bh-KH 167.***.***.200 in /etc/alwaysrelay trusting from_h_domain of: gmail.com and from_h_localpart: my_sending_email
1ezbTk-0004Bh-KH SMTP connection outbound 1521868353 1ezbTk-0004Bh-KH gmail.com [email protected]
1ezbTk-0004Bh-KH => [email protected] R=lookuphost T=remote_smtp H=10.3.37.200 [10.3.37.200] C="250 2.0.0 Ok: queued as 179E48157D"
1ezbTk-0004Bh-KH Completed
It repeats the same exact message (with different ID's) 10 times, then stops. I see the headers in my Gmail message.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello,

To update, it looks like updating the email routing setting from "Auto" to "Local" solved the issue. The "Local" setting ensures the domain name exists in the /etc/localdomains file and that local email is correctly routed to the cPanel server.

Thank you.
 

renecd

Member
Mar 26, 2020
11
1
3
badland-vibes-tackiness-handoff
cPanel Access Level
DataCenter Provider
Sorry to hijack this old topic, but I'm playing with the idea of setting up a PMG for my Cpanel server, like the op here. My question is - wouldn't you have to add all your domains manually to the PMG? For a Cpanel server with hundreds of domains, and resellers that add and remove domains on their own, wouldn't that cause a lot of management overhead? How do you deal with that?
 

gramzon

Active Member
Dec 4, 2017
32
5
58
Croatia
cPanel Access Level
Root Administrator
Sorry to hijack this old topic, but I'm playing with the idea of setting up a PMG for my Cpanel server, like the op here. My question is - wouldn't you have to add all your domains manually to the PMG? For a Cpanel server with hundreds of domains, and resellers that add and remove domains on their own, wouldn't that cause a lot of management overhead? How do you deal with that?
And why would you want to do that anyway? Since PMG is essentially just Spam Assassin + ClamAV.