Relaying mail to normal mailserver

We are not an ISP, so this server will be primarily used to host our company website, intranet, plus the websites of a handful of associated businesses. Previously our websites were hosted by an external ISP. As we have not yet gone live, most of the domains continue to be hosted by that ISP, including the primary domain specified in the ISPConfig Settings. This primary domain is also our internal network domain and its "www" is our company website. Because the DNS for most of our domains continue to be handled by external ISPs, I have not yet ticked the various DNS checkboxes.

For the domain names relating to our main company website and intranet, I wish all the email to be handled by our normal mailserver, so that emails generated by CGI scripts on the server with recipient "[email protected]" should end up in the mailbox "name" on our normal mail-server.

For these domains I have set each site to use "External mailserver" in ISPConfig. Presumably this just does a DNS lookup for the MX record for the domain, regardless of whether the DNS is handled locally or not? I have added our mail-server to the hosts table, although I am not sure that this is strictly necessary as presumably it would be found by the normal DNS resolution.

The problem is that the emails generated by our Intranet CGI scripts are building up in /var/mail/web1_<username> instead of being relayed to our mailserver.

Any thoughts on how to resolve this problem? (I would like to retain the flexibility of being able to use the ISPConfig handling of mail for the other sundry domains, perhaps by Webmail or POP3.)

For these domains I have set each site to use "External mailserver" in ISPConfig. Presumably this just does a DNS lookup for the MX record for the domain, regardless of whether the DNS is handled locally or not?

Click to expand...

Setting domains to external mailserver removes the domain from the local mailserver configuration. This means postfix will deliver these emails like any other external email to the mailserver specified in the MX record of the domain.

The problem is that the emails generated by our Intranet CGI scripts are building up in /var/mail/web1_<username> instead of being relayed to our mailserver.

Any thoughts on how to resolve this problem? (I would like to retain the flexibility of being able to use the ISPConfig handling of mail for the other sundry domains, perhaps by Webmail or POP3.)

Click to expand...

You must set the the mailserver to external in the settings of all co-domains too.

Thanks both. I have found the following line in syslog (yes, the first place I should have looked, sorry!):

mail for ourprimarydomain.co.uk loops back to myself

Click to expand...

This particular web is our Intranet, so I have set the IP address as the LAN IP, the hostname as "intranet" and the domain as ourprimarydomain.co.uk. It is set, as previously stated, to use "External mailserver", which I would have expected to resolve to mail.ourprimarydomain.co.uk (which is where the primary MX record for ourprimarydomain.co.uk points).

As this web is for internal use only, I was not intending setting up DNS for the domain, so I have not created an A-record for "intranet", but have instead updated hosts tables on the machines that need to connect.

Just in case the web having an internal IP address was causing problems, I set mail.ourprimarydomain.co.uk in /etc/hosts.

I did try setting the web's IP address to the WAN address, but immediately the intranet was unavailable internally (and externally obviously given the lack of an A-record!).

I am starting to doubt my sanity now. The problem was ever so simple, in the process of trying to resolve my previous problem Preventing http access by IP address whilst keeping our Intranet working, I had created a dummy DNS A record for our intranet (and had not created an MX record). I have now deleted this DNS entry, removed the entries in the /etc/hosts table and it now, surprise surprise, works.

I am sorry to have wasted your time - the entries in DNS Manager seemed to neatly mirror those in ISP Manager - so the problem was not immediately apparent until after I had had my fifth double expresso!