Search code examples
emailpostfix-mta

Postfix: loops back to myself error


I've been trying to install a Postfix server for handling mail for my domain. I found some nice tutorial and I was able to create email address and server responds correctly with telnet (imap and pop3 included, I also charge the config in Gmail and works correctly).

To handle POP3 and IMAP I have installed Courier

The problem comes when I try to send e-mails to myself (with external email address), I receive the following error code:

Action: failed
Status: 5.4.6
Diagnostic-Code: X-Postfix; mail for (servername) loops back to
myself

I reviewed my postfix mail.conf config, as in many webs they said that it could be because mydestination was not corectly configured. I have included the domain configuration and I still get the same error. (/etc/postfix/main.cf)

mydestination = mail.mydomain.com, domain.com, localhost

This is in a VPS, so the hostname is different to the domain name, I'm not sure if this can have any influence on the handling mail error.

Could someone help me to find where can the error be?

Thanks for your attention and your answers


Solution

  • You're probably sending mail to a recipient, with an email address in a zone which has an MX record, with its value a hostname, which resolves to the ip address of your mailserver, while this your server hasn't been told in its main.cf config file (behind mydestination), that it is referring to itself.

    Therefore, your server is wondering why an attempt to send mail to - as it believes - another server results in finding that the ip address of that another server is its own ip address.

    Update mydestination accordingly.

    It helps to use the same hostname for MX record, for all zones your mailserver handles incoming mail for, as that keeps your mydestination manageable.