• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

*solved* Postfix 'mail for domain.com loops back to myself'

Status
Not open for further replies.

IDFarm

New Pleskian
Hello all,

We are experiencing the 'mail for domain.com loops back to myself' issue on our VPS.
The domain.com always had it's e-mail handled via an Exchange-server located outside of the Webdomain.
Let's call the Exchange-server's ip 'exchange.server.ip'
We recently moved domain.com to a new VPS and and we're experiencing the issue where every e-mail that is sent via the webserver (PHP mail()) does not get routed to the external Exchange-server.
I've searched the internet for this issue, and it seemed alot of threads/posts suggest solving this issue by changing the 'mydestination' parameter in the main.cf config file. However I tried multiple different setings, and all of them gave the following log-entries when trying to send a mail via the webserver to a @domain.com e-mailaddress:
Code:
Dec  3 09:39:16 domain postfix/smtp[21523]: warning: host mail.domain.com[exchange.server.ip]:25 greeted me with my own hostname domain.com
Dec  3 09:39:16 domain postfix/smtp[21523]: warning: host mail.domain.com[exchange.server.ip]:25 replied to HELO/EHLO with my own hostname domain.com
Dec  3 09:39:16 domain postfix/smtp[21523]: C3D8F66E18: to=<[email protected]>, relay=mail.domain.com[exchange.server.ip]:25, delay=0.08, delays=0/0.01/0.07/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
Dec  3 09:39:16 domain postfix/qmgr[4423]: C3D8F66E18: removed

I've added the postconf output file as 'main config.txt'. Some changes I made during testing might still be present in the config. (i.e. mydestination parameter is empty)

Since this probably has something to do with DNS settings, I've added the DNS-settings for the domain where we try to send the mail from:
Code:
vps.server.ip / 24   PTR   domain.com.
fallbacks4.domain.com.   A   217.115.195.25
ftp.domain.com.   CNAME   domain.com.
ipv4.domain.com.   A   vps.server.ip
domain.com.   NS   ns.domain.com.
domain.com.   A   vps.server.ip
domain.com.   MX (10)   mail.domain.com.
domain.com.   MX (30)   fallbacks4.domain.com.
domain.com.   TXT   v=spf1 +a +mx -all +a:domain.com
localhost.domain.com.   A   127.0.0.1
mail.domain.com.   A   exchange.server.ip
ns.domain.com.   A   vps.server.ip
webmail.domain.com.   A   vps.server.ip
www.domain.com.   CNAME   domain.com.

Summary:
Moved existing websites to a new VPS. E-mail has always been handled by an (external) Exchange-server.
Now the webserver on which the domain runs tries to handle sending the mail, without processing the MX-records (I believe) and routing it to the external Exchange server.

It is probably pretty obvious I am by no means an expert with CentOS and postfix, so I hope I am not missing a simple thing.

Hopefully someone knows why this is occuring, and knows a solution.

Thanks in advance!

Rowan
 

Attachments

  • main config.txt
    2 KB · Views: 28
Hi Rowan,

I suggest to check the DNS - settings on your providers nameserver, because they might not be set the same, as you set them in Plesk. Be aware that the nameserver on your VPS is not the primary nameserver, when you don't own the different IPs and just rented them from your provider. You could check if your settings meet your desires, by using i.e. "http://mxtoolbox.com/SuperTool.aspx".
 
Hi UFHH01,
Thanks for replying in such short notice.

We've noticed there indeed might be a problem with the DNS/domain transfer to the new hosting-provider and VPS.
Apparently the domain-transfer to the new hosting-provider hadn't completed correctly.
We are currently completing the domain-transfer, and hopefully this will fix the issue.

I will report back when I know more.

Rowan
 
Time for a follow-up.
We still haven't figured out why this is not working.
We have recently moved the domain to the provider that also runs the VPS, and can now set the DNS-settings for the domain in the control panel for the domain at the hosting provider.
It seems the DNS-settings provided in the OP were not correct, and the actual DNS settings are as follows:
Code:
* CNAME @
@ A vps.server.ip
@ MX 10 mail.domain.com.
@ MX 20 backup.server.
@ TXT SPF record
ftp CNAME @
mail A exchange.server.ip
However this hasn't provided any improvements. It does seem the DNS-settings are now correct:
The nameserver that is used now for the domain matches the nameserver for the VPS.
The mail.domain.com now correctly resolves to the exchange.server.ip, also (I believe) demonstrated in the 'relay=mail.domain.com[exchange.server.ip]:25' below.
Dec 11 08:56:38 user postfix/smtp[9690]: B814566E42: to=<[email protected]>, relay=mail.domain.com[exchange.server.ip]:25, delay=0.15, delays=0.05/0.03/0.07/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
The following (new) error messages are now present in the maillog:
Code:
Dec 11 08:56:38 user postfix/qmgr[4803]: B814566E42: from=<[email protected]>, size=754, nrcpt=2 (queue active)
Dec 11 08:56:38 user postfix/smtp[9690]: warning: host mail.domain.com[exchange.server.ip]:25 greeted me with my own hostname domain.com
Dec 11 08:56:38 user postfix/smtp[9690]: warning: host mail.domain.com[exchange.server.ip]:25 replied to HELO/EHLO with my own hostname domain.com
Note the from=<user@domain.nl>, I am sending these test-mails from the .nl domain (the website runs 2 different websites on .com and .nl)

It still seems like the internal resolver on the VPS doesn't use the actual MX records, or just ignores them?

Hopefully this provides more information, since we aren't actually finding out more about this issue.

Thanks for helping.

Rowan
 
You should consider modifying your "backup.server" with different hostname and host - configurations, both located at "/etc/". At the moment you seem to have configured both only with the global definition "localdomain".

Example for exchange.server.ip ( /etc/hostname ):

server1.example.com

Example for exchange.server.ip ( /etc/hosts ):

127.0.0.1 localhost.localdomain localhost
XXX.XXX.XXX.XXX server1.example.com server1

Example for backup.server ( /etc/hostname ):

server2.example.com

Example for backup.server ( /etc/hosts ):

127.0.0.1 localhost.localdomain localhost
XXX.XXX.XXX.XXX server2.example.com server2
 
I'm not sure if this would be helpful in your scenario, but I was in similar situation couple of times and each time this was related to mail settings for the domain in plesk.
  1. When external exchange server is used it is important to set up correct MX record on the domain
  2. When you try to send email from the same server plesk tries to deliver it locally first and loops
Solution in all cases I have come across was to disable email services for the domain as email is not handled locally. Give it a go.
In your plesk panel go to Domains>yourdomain.com>Mail and untick Activate mail service on this domain. Let me know if it helps.
 
I'm not sure if this would be helpful in your scenario, but I was in similar situation couple of times and each time this was related to mail settings for the domain in plesk.
  1. When external exchange server is used it is important to set up correct MX record on the domain
  2. When you try to send email from the same server plesk tries to deliver it locally first and loops
Solution in all cases I have come across was to disable email services for the domain as email is not handled locally. Give it a go.
In your plesk panel go to Domains>yourdomain.com>Mail and untick Activate mail service on this domain. Let me know if it helps.
Thanks weelk, We already did this, but thanks for suggesting this.
I am currently looking into the problem again, and we might have solved it.

Will report back if we indeed found the solution.

Thanks to UFHH01 for more information.

Rowan
 
Alright, the problem is in fact resolved.
The issue seemed to be some settings in the postfix main.cf.
During testing I added the following line to the main.cf which seemed to be to error:
Code:
myhostname = domain.com
Also we made edited the config to:
Code:
myhostname = mail.domain.com
mydomain = domain.com
mydestination = mail.$mydomain

After changing these setting in the configuration the mail-delivery is once again working.
It seems that during testing the configuration we've not cleaned up the actual config, and looking through the entire main.cf file we found the actual errors.

Hopefully this information provides other users help if they have the same issues.

Thanks everyone who provided information.

Rowan
 
Status
Not open for further replies.
Back
Top