Courier / Postfix - tweaking settings to send mail outside the server all the time

Associate
Joined
19 Jun 2003
Posts
1,680
Location
West Yorks, UK
Hi,
This should be an easy one i hope. I have a dedicated web server running Fedora Core 3 - it hosts multiple websites.

There is an issue with the Courier / Postfix configuration where email is routed internally before any attempt is made to send it externally. One of the sites I host has an MX record on the domain to send mail straight to the companies server - hence no email accounts are setup for it. Therefore when I send email from PHP scripts and the like, Postfix tries to route the mail internally (as the website domain is hosted on the same server, so it thinks its internal), finds no email addresses to send it to, and returns a "Mail cannot be delivered" error.

In the postfix config in /etc/postfix/main.cf, I have found the following:
Code:
Code:
mydestination= $myhostname, localhost.$mydomain

Should this be changed to:
Code:
Code:
mydestination= $myhostname, mail.$mydomain

...or would that just route mail outside to the main domain on the server? Any thoughts?

Matt
 
You just need to ensure Postfix doesn't consider the domain name you are sending to as local. Is it $myhostname you're having a problem with? I guess you could just remove that but I'm not entirely sure if that would break anything... I guess the proper way to do it is to use Postfix's transport table and point that domain to the correct mailserver (i.e. the true primary MX for $myhostname).
 
Ah right. There is a file that lists the domain names that are hosted on the server using Apache. It looks a bit like this:

domain.com maildrop:
anotherdomain.com maildrop:

Etc etc. Should I be adding something into there then?

Matt
 
If that's /etc/postfix/transport then yes.

Find the entry for the domain that you don't want to be handled locally and change it to:

Code:
example.com     relay:[smtp.myisp.com]

That will tell postfix to send the mail straight to that host where "smtp.myisp.com" is your ISP's mailserver which will then deliver it as normal.

I am sure there are loads of different ways of doing this and I haven't actually tested but I think that should work :)
 
Back
Top Bottom