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 email@example.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?
Thanks for your help,
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.
Thanks for you help - I went through and disabled the Mail for Domain option along with each dependancy until I got to this one:
“Failed to modify server : A target server must have email enabled if any aliases do”
I’ll have a dig around to see if I can find these - I remember seeing some within postfix? Any pointers to the contrary would be greatly appreciated
thought I’d post back the solution to my last query to help anyone with the same problem.
I have an aliased domain pointing to another domain e.g. domain.com is an alias of domain.co.uk
I simply had to click on Edit Virtual Server in domain.com and then disable the “Mail for domain enabled” link under enabled features.
My php script executes without error, but the email still does not send.
I’ve checked postfix and nothing has appeared in the queue. Anyone any ideas what I should be checking?
Thanks in advance, Paul
My recommendation would be to look in the mail logs at the time the email was created – that would be in /var/log/maillog.
Also, if there was a PHP error of some kind, that would show up in the Apache error logs, located in $HOME/logs/error_log.
Did Postfix log anything at the time the mail was attempted to be sent? Or maybe some PHP error is in the Apache log?
EDIT: Eric was faster, I should have reloaded the thread before replying.
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.
Feb 4 22:31:01 server9999 postfix/pickup: F42155BEB55: uid=500 from=
Feb 4 22:31:01 server9999 postfix/cleanup: F42155BEB55: message-id=20110204223100.F42155BEB55@server9999.localdomain
Feb 4 22:31:01 server9999 postfix/qmgr: F42155BEB55: firstname.lastname@example.org, size=645, nrcpt=1 $
Feb 4 22:31:01 server9999 postfix/smtp: F42155BEB55: email@example.com, relay=none, delay=0.07, delays=0.$
Feb 4 22:31:01 server9999 postfix/cleanup: 0F51C5BEB56: message-id=20110204223101.0F51C5BEB56@server9999.localdomain
Feb 4 22:31:01 server9999 postfix/qmgr: 0F51C5BEB56: from=<>, size=2509, nrcpt=1 (queue active)
Feb 4 22:31:01 server9999 postfix/bounce: F42155BEB55: sender non-delivery notification: 0F51C5BEB56
Feb 4 22:31:01 server9999 postfix/qmgr: F42155BEB55: removed
Feb 4 22:31:01 server9999 postfix/smtp: 0F51C5BEB56: firstname.lastname@example.org, relay=none, delay=0.$
Feb 4 22:31:01 server9999 postfix/qmgr: 0F51C5BEB56: removed
It looks like postfix is still handling the mail and treating it as “local”. I notice that internal it is sent as email@example.com - 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?
Thanks for your help - appreciated.
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.
You can do that by typing:
Then, restart Postfix:
After that, do things begin working correctly?
The name server9999 was assigned by the VPS company and is not FQ, I have raised a ticket with them to ask for the FQDN.
I’ll let you know how I get on.
Thanks again for your help,
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: C38045BEB55: uid=500 from=
Feb 5 16:07:38 server7940 postfix/cleanup: C38045BEB55: message-id=20110205160738.C38045BEB55@sub.mydomain1.tld
Feb 5 16:07:38 server7940 postfix/qmgr: C38045BEB55: firstname.lastname@example.org, size=643, nrcpt=1 (queue a$
Feb 5 16:07:38 server7940 postfix/smtp: C38045BEB55: email@example.com, relay=none, delay=0.03, delays=0.$
Feb 5 16:07:38 server7940 postfix/cleanup: CC44A5BEB56: message-id=20110205160738.CC44A5BEB56@sub.mydomain1.tld
Feb 5 16:07:38 server7940 postfix/qmgr: CC44A5BEB56: from=<>, size=2471, nrcpt=1 (queue active)
Feb 5 16:07:38 server7940 postfix/bounce: C38045BEB55: sender non-delivery notification: CC44A5BEB56
Feb 5 16:07:38 server7940 postfix/qmgr: C38045BEB55: removed
Feb 5 16:07:41 server7940 postfix/smtp: CC44A5BEB56: firstname.lastname@example.org, relay=ASPMX.L.GOOGLE.COM[209.$
Feb 5 16:07:41 server7940 postfix/qmgr: 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 email@example.com, 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 firstname.lastname@example.org and email@example.com 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: C78815BEB55: firstname.lastname@example.org, 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 email@example.com was simply postfix attempting to send a failed delivery notification.
Getting closer (I hope!)
I checked the spam folder for mydomain1.tld and there were the mail delivery failure notifications, one read:
I’m sorry to have to inform you that your message could not
be delivered to one or more recipients. It’s attached below.
For further assistance, please send mail to
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
firstname.lastname@example.org: mail for firmusvehicles.co.uk loops back to myself
Final-Recipient: rfc822; email@example.com
Diagnostic-Code: X-Postfix; mail for firmusvehicles.co.uk loops back to myself
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:
mail for firmusvehicles.co.uk loops back to myself
Ay pointers greatly appreciated!
I thought I’d post back the solution to my problem to help those who have the same issue / didn’t know the answer.
In the end I added additional MX entries to BIND DNS for googlemail. It took a couple of restarts to postfix to apply the settings.
The maillog now shows the correct googlemail address in the “relay=” field.
I have this same problem on a CentOS 5.6 / VMin 3.86 Pro box.
A PHP script sending mail tries to send to firstname.lastname@example.org. 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)?
Disable the DNS service and the Mail service for the domain you’re trying to send mail to (if mail is hosted elsewhere).
Interestingly, I’m now having this problem on a domain (with subdomains) that does have DNS and Mail for domain both disabled…
Authoritative DNS resolves MX correctly to the internet host which handles the domain’s email, but I’m still seeing mails to BOUNCE@<myhost.com>.
Anyone care to comment?