Tuesday, June 11, 2013

my mail not being delivered. (Postfix + Plesk)



A while back, I was having an issue with my mail not being delivered. I would write a function using 

< ? 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.  

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

I can’t explain how helpful it was.
Find your ‘main.cf’ configuration file for PostFix, which for CentOS 6, is located at 

 /etc/postfix/main.cf 
If you can’t find it, do a
# 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) :

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 :

#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. 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:
 /usr/local/psa/var/log/maillog 
although for most Linux OS, they are located
 /var/log/maillog