PostFix Local Loop in PLESK

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

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

 /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 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:

 /usr/local/psa/var/log/maillog

although for most Linux OS, they are located

 /var/log/maillog

On mine, I noticed that the output for that particular email kept saying

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
</name@company.com></my.valid.email@myserver.com>

On line 2, you can see that Postfix begins a

 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!

14 Comments

  • I had the same error messages in my mail log on my 1&1 VPS server, running Plesk 18.0.26.

    Mail wasn’t arriving in the inbox of a previously functional email account. I sent some more messages to the address and saw from the log that the message was being routed to localhost@localdomain, where there was no mailbox, rather than to the actual mailbox directory at my server.com. It was the Plesk virtual service which was doing this:

    May 2 08:21:49 server postfix-local[46083]: cannot chdir to mailname dir my.valid.email: No such file or directory
    May 2 08:21:49 server postfix-local[46083]: Unknown user: my.valid.email@localhost.localdomain
    May 2 08:21:49 server postfix/pipe[46082]: 3D3C610A1E07: to=, orig_to=, relay=plesk_virtual, delay=0.52, delays=0.42/0.01/0/0.09, dsn=2.0.0, status=sent (delivered via plesk_virtual service)
    May 2 08:21:49 server postfix/qmgr[31578]: 3D3C610A1E07: removed

    I found a solution here:

    https://support.plesk.com/hc/en-us/articles/360006766894-Mail-not-delivered-to-a-mailbox-User-unknown-in-virtual-mailbox-table

    The short answer is that it was a permissions issue, fixed with this command in ssh:

    plesk repair mail example.com -y

    Probably worth trying this before you comment out the virtual mailbox table entries in Postfix, change subscriptions, or scrap email addresses.

  • It is 6 years later but Seanie’s solution still worked for me. I was using the same email in the Profile that I was using for a subscription. After several hours of working on this it was good to finally solve it just by changing an email.

  • With the newer version (disable emailservice for this domain), the users couldn’t login their email accounts anymore. (Plesk 17.5)
    When I commented out the three lines from above (and restarted postfix+apache), the local delivery was disabled and everything was delivered to the right relayhosts.

    The thing was – you couldn’t recieve emails anymore – I got:
    454 4.7.1 : Relay access denied;
    (tried it with a working domain, no worries ^^)

    This feels to be the right way, but Plesk does not seem to recognize it’s recepience anymore.

    Has there been a workaround lately?

  • I’ve been struggling with this issue for a while now on our 1&1 Plesk server – thanks so much, this fixed it for me!

  • Thanks Thanks Thanks Thanks, That fixed my issue in a vps server

  • Dude!! You Rock!!!

  • Hi Neil!

    Thx Dude for this awsome solution! :) You made my day! :)

    Regards!

    tetrapac

  • Hi,

    I had the same issue, commenting those three lines:

    #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

    …could be a fix for 1and1 webmail use.

    But, if u want to use the roundcube email on 1and1 dedicated server, commenting those lines will broke postfix, the roundcube emails will not work. (you can send but u’ll be not able to recive external emails)
    A quick solution for that could be: /usr/local/psa/bin/mail –off domain.tld (turning off the subscription emails)

  • Thanks a million..! That fixed my issue…

  • had the same problem, it is related to the virtual mappings not re-writing properly.
    Turns out the issue related to the email address in the Main Panel Profile being the same as the contact email on a subscription.

    Click on Profile & Preferences in the Left Column and check the email address in there. Then see if any subscription has the same one. If so, change it.

    You might need to add or modify a subscription then, to get the table re-written properly.

    Hope that sorts it for you. Solved it for me.

  • Hi, I had exactly this problem and your solution worked for me well. But…

    Since I made this changes local mail delivery on other domains does not work anymore!

    Means, e.g. dmail.at is located on this plesk server and is our primary mail domain. On this domain no mails are delivered anymore. It is dead, lets say…

    Do you have any idea how to combine your solution with the old state?

    Thanks in advance!

    AceLine

  • Haha, no problem. I spent hours pulling my hair out trying to figure out why this was happening. Same thing, PLESK on a 1&1 dedicated server. They don’t really give you much heads up as to what to do when you get it (as it was my first ded. server), but trust me, after 6 months, you’ll be an expert. Glad you could figure it out!

  • I could hug you. This helped me fix my email issue on my new 1and1 dedicated server. Cheers!

  • thank you!!!

Leave A Comment

Your email address will not be published. Required fields are marked *