Apologies if this question has already been raised, I have performed a thorough search and could not find anyone with the same problem as me.
I am running virtualmin on top of CentOS 5.5. I have created a simple php contact page that sends via the php mail function. This is hosted on Apache under the virtualhost account of domain.com. The email for domain.com is hosted on another server (googlemail in this instance) but when I attempt to send the contact details to info@domain.com, Postfix picks this up as a “local” account.
My question is, how do I tell postfix to ignore the email for domain.com and pass it back out into the ether for routing to googlemail?
What you’re seeing could occur if the “Mail for Domain” feature was enabled for that particular Virtual Server.
To check that, go into Edit Virtual Server for the domain in question, and look at the Enabled Features. If Mail for Domain is enabled, you’d want to disable that if the email is hosted elsewhere.
Thank you both for your pointers - Here is the relevant output from the maillog, after I fired the php script. The apache log just had lines relating to fav.ico and requests for other pages by crawlers but nothing relating to my php pages.
–MAILLOG–
Feb 4 22:31:01 server9999 postfix/pickup[6779]: F42155BEB55: uid=500 from=
Feb 4 22:31:01 server9999 postfix/cleanup[7878]: F42155BEB55: message-id=20110204223100.F42155BEB55@server9999.localdomain
Feb 4 22:31:01 server9999 postfix/qmgr[2811]: F42155BEB55: from=firmusvehicles@localdomain.localdomain, size=645, nrcpt=1 $
Feb 4 22:31:01 server9999 postfix/smtp[7880]: F42155BEB55: to=info@firmusvehicles.co.uk, relay=none, delay=0.07, delays=0.$
Feb 4 22:31:01 server9999 postfix/cleanup[7878]: 0F51C5BEB56: message-id=20110204223101.0F51C5BEB56@server9999.localdomain
Feb 4 22:31:01 server9999 postfix/qmgr[2811]: 0F51C5BEB56: from=<>, size=2509, nrcpt=1 (queue active)
Feb 4 22:31:01 server9999 postfix/bounce[7881]: F42155BEB55: sender non-delivery notification: 0F51C5BEB56
Feb 4 22:31:01 server9999 postfix/qmgr[2811]: F42155BEB55: removed
Feb 4 22:31:01 server9999 postfix/smtp[7880]: 0F51C5BEB56: to=firmusvehicles@localdomain.localdomain, relay=none, delay=0.$
Feb 4 22:31:01 server9999 postfix/qmgr[2811]: 0F51C5BEB56: removed
It looks like postfix is still handling the mail and treating it as “local”. I notice that internal it is sent as firmusvehicles@localdomain.localdomain - which I’m guessing is wrong?
What output do you receive if you run the command “hostname” on your server?
Whatever that output is, you should have that name next to your external IP in /etc/hosts, as well as on the mydestination line of /etc/postfix/main.cf.
If you make any changes to those files, you’d want to restart Postfix afterwards, using “/etc/init.d/postfix restart”.
The hosts file contains the server IP and a fqn I specified when I installed virtualmin, the hostname command returned server9999, which should I change? I use the FQN to access virtualmin, so can I simple add server9999 into the hosts file with the same IP?
It looks like your hostname isn’t actually an FQDN, which may be part of the issue you’re seeing.
So if your FQDN should be server9999.domain.tld, and that’s the name that shows up in /etc/hosts and /etc/postfix/main.cf – try setting your hostname to be server9999.domain.tld.
I’ve set the hostame to sub.mydomain1.tld, and ensured that mydestination in main.cf reflects that.
Now when I send I receive:
Feb 5 16:07:38 server7940 postfix/pickup[4601]: C38045BEB55: uid=500 from=
Feb 5 16:07:38 server7940 postfix/cleanup[6944]: C38045BEB55: message-id=20110205160738.C38045BEB55@sub.mydomain1.tld
Feb 5 16:07:38 server7940 postfix/qmgr[30714]: C38045BEB55: from=firmusvehicles@mydomain1.tld, size=643, nrcpt=1 (queue a$
Feb 5 16:07:38 server7940 postfix/smtp[6946]: C38045BEB55: to=info@firmusvehicles.co.uk, relay=none, delay=0.03, delays=0.$
Feb 5 16:07:38 server7940 postfix/cleanup[6944]: CC44A5BEB56: message-id=20110205160738.CC44A5BEB56@sub.mydomain1.tld
Feb 5 16:07:38 server7940 postfix/qmgr[30714]: CC44A5BEB56: from=<>, size=2471, nrcpt=1 (queue active)
Feb 5 16:07:38 server7940 postfix/bounce[6947]: C38045BEB55: sender non-delivery notification: CC44A5BEB56
Feb 5 16:07:38 server7940 postfix/qmgr[30714]: C38045BEB55: removed
Feb 5 16:07:41 server7940 postfix/smtp[6946]: CC44A5BEB56: to=firmusvehicles@mydomain1.tld, relay=ASPMX.L.GOOGLE.COM[209.$
Feb 5 16:07:41 server7940 postfix/qmgr[30714]: CC44A5BEB56: removed
It may be worth mentioning that I have mutlidomains hosted on my VPS, and the MX records for mydomain1.tld point to googlemail (via a separate DNS)
So I’m now thinking that postfix resolves the MX records ad pulls back ASPMX.L.GOOGLE.COM for relay, my first concern is that the outgoing email address looks like it’s being changed to firmusvehicles@mydomain1.tld, and secondly googlemail might bounce the email as the sender (mydomain1.tld) mx records are held on googles servers??! I hope that makes sense!!
Needless to say I have checked firmusvehicles@mydomain1.tld and info@firmusvehicles.co.uk and nothing has come through.
It’s hard to say why you didn’t get it, as according to the logs above, the message was accepted by Google’s servers.
The “From” that you see in the logs isn’t the “From” address listed in the email – it’s the name of the account sending the message (which in some cases is the same as the From address, and in other cases is different). However, that shouldn’t matter to Google.
Just to clarify – email for that domain is hosted at Google?
And if you send an email from another source (your home PC, for example) – are you then able to send a message to that account which arrives in your Google mailbox?
You may want to glance in your spam folder just in case it ended up there…
And I also noticed that the old hostname still appears, I had restarted postfix as directed, but I’ll be investigating where this is being picked up - my hosts file only shows sub.mydomain1.tld.
Another clue lies in the mail log, the line below was truncated from output included in the thread above:
Feb 5 16:34:09 server7940 postfix/smtp[7858]: C78815BEB55: to=info@firmusvehicles.co.uk, relay=none, delay=0.04,
delays=0.03/0/0/0, days=0.03/0/0/0, dsn=5.4.6, status=bounced (mail for firmusvehicles.co.uk loops back to
myself)sn=5.4.6, status=bounced (mail for firmusvehicles.co.uk loops back to myself)
Mail for domain is disabled.
I’m also guessing that in my previous post firmusvehicles@mydomain1.tld was simply postfix attempting to send a failed delivery notification.
So there must be something else which is stopping email being routed out - especially true as both mydomain1.tld and firmusvehicles.co.uk have email hosted by google, and there doesn’t seem to be a problem with mydomain1.tld.
I have spent some time reading through the postfix man pages, specifically around the virtual_alias_domain and mydestination fields, I’ve tried a few things but nothing seems to allow postfix to forward an email sent from my php mail script.
So basically I have a virtualhost setup for domain.com - I have unchecked the Mail for domain enabled option and dependancies. Email bound for domain.com is routed to googlemail.
The php mail function attempts to send two emails - one to domain.com and one to otherdomain.com. otherdomain.com is not a virtualhost on the server and gets delivered successfully. For domain.com, the email arrives in the local mailbox called domain, the error message contained within reads:
I have this same problem on a CentOS 5.6 / VMin 3.86 Pro box.
A PHP script sending mail tries to send to user@domain.com. domain.com is hosted on my box, but email for it is hosted with Google.
I’ve tried adding MX records to domain.com’s DNS records (on the server), which didn’t fix this. But I’m thinking the local DNS records shouldn’t necessarily be used as they’re not authoritative for that domain.
Is your VMin server storing authoritative DNS records for your domain, or are they stored elsewhere (perhaps with the domain registrar’s name servers)?