PostFix Local Loop in PLESK
April 12, 2012
THIS ARTICLE IS A SOLUTION FOR PLESK 10.4 AND EARLIER.
TO VIEW THE MOST UPDATED ARTICLE, VISIT HERE
The problem
A while back, I was having an issue with my mail not being delivered. I would write a function using
1 |
< ? php mail(); ? > |
and it would successfully send an email to every address EXCEPT one particular address. I couldn’t tell why. This is something that occurs on Parellels’ PLESK server administration software.
The solution
I’ll get to it awfully quick, then I’ll tell you how I figured it out.
First, you need to ask yourself, is this email address the same domain being hosted on PLESK? Bingo. The problem was that when PostFix (the SMTP sendmail uses by default in most cases) determined the address to be the same as the domain it was hosting, it did a local search to find that address rather than just sending the email.
Naturally, if you didn’t have that particular email address set up, or any email with that extension set up on the server, it found nothing, and wouldn’t send the email. There is a very easy fix to this issue by commenting out 3 lines in your Postfix ‘main.cf’ configuration file. This was originally documented by Luke Tarplin, and I can’t explain how helpful it was.
Find your ‘main.cf’ configuration file for PostFix, which for CentOS 6, is located at
1 |
/etc/postfix/main.cf |
If you can’t find it, do a
1 |
# which postfix |
SSH command to at least see where Postfix is on your server.
Then, open the file up through a text editor, or in the Linux shell, and make these lines (should be at the end of the file, around line 677) :
1 2 3 |
virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox |
commented out like this :
1 2 3 |
#virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains #virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual #virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox |
Then, restart the Postfix service, and Apache while your at it (can’t hurt), and voila! Your email address should be receiving those emails now. This also doesn’t affect any of your regular emails or anything else, either.
Now, I figured out how to look for this by checking over my mail logs. Any time you have an error with sending an email, check your mail logs. For CentOS, they are located:
1 |
/usr/local/psa/var/log/maillog |
although for most Linux OS, they are located
1 |
/var/log/maillog |
On mine, I noticed that the output for that particular email kept saying
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Apr 10 10:26:29 ######### postfix/qmgr[8323]: 19EA21827: from= <my.valid.email@myserver.com>, size=645, nrcpt=1 (queue active) Apr 10 10:26:29 ######### postfix-local[8331]: postfix-local: from=my.valid.email@myserver.com, to=name@company.com, dirname=/var/qmail/mailnames Apr 10 10:26:29 ######### postfix-local[8331]: cannot chdir to mailname dir name: No such file or directory Apr 10 10:26:29 ######### postfix-local[8331]: Unknown user: name@company.com Apr 10 10:26:29 ######### postfix/pipe[8330]: 19EA21827: to=<name@company.com>, relay=plesk_virtual, delay=0.15, delays=0.11/0/0/0.04, dsn=2.0.0, status=sent (delivered via plesk_virtual service) Apr 10 10:26:29 ######### postfix/qmgr[8323]: 19EA21827: removed |
On line 2, you can see that Postfix begins a
1 |
postfix-local[####] |
search. That was a dead giveaway that for some reason PostFix was reverting to a local search. I put 2 and 2 together and starting searching for the appropriate solution.
If, for some reason, you happen to have similar circumstances but this isn’t the right solution, just remember : Always check your mail logs. It has everything you could ever need to know in fixing a problem. Good luck and happy coding!