Site icon Carlos Herrera

Solution: “User unknown in virtual alias table” Error in Plesk

Problem Description

When you have a Plesk server managing hosting and DNS for a domain, but email is hosted on an external service (such as Office 365, Google Workspace, etc.), you may encounter this error when trying to send emails from other domains on the same server:

User unknown in virtual alias table

Typical Scenario

Why Does This Error Occur?

Postfix (Plesk’s mail server) considers that if a domain is hosted on the server (even if only for hosting/DNS), it should deliver mail locally. This happens because:

  1. The domain exists in Postfix’s virtual tables (/var/spool/postfix/plesk/virtual)
  2. Postfix queries virtual_alias_domains before transport_maps
  3. It finds the domain as “local” and doesn’t query external MX records
  4. It attempts to find the mailbox locally and fails with “User unknown”

Diagnosis

1. Check if the domain is in the virtual tables:

postmap -q yourdomain.com hash:/var/spool/postfix/plesk/virtual

If it returns something (like “1”), the domain is registered as a local virtual domain.

2. Check the current configuration:

postconf virtual_alias_domains

If it shows virtual_alias_domains = $virtual_alias_maps, that’s the problem.

3. Verify that external MX records are configured:

dig yourdomain.com MX +short

Should display external mail servers (e.g., yourdomain-com.mail.protection.outlook.com)

Complete Solution

Step 1: Disable Mail Service in Plesk

  1. Access Plesk → Websites & Domains → yourdomain.com
  2. Go to Mail → Mail Settings
  3. Select “Not configured”
  4. Save changes

Step 2: Configure Transport Maps

Add the domain to the transport file to force external delivery:

echo "yourdomain.com smtp:" >> /var/spool/postfix/plesk/transport
postmap /var/spool/postfix/plesk/transport

Step 3: Modify virtual_alias_domains

Edit Postfix’s main configuration:

vi /etc/postfix/main.cf

Find the virtual configurations section (near these 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

Add this line right after:

virtual_alias_domains =

Important: Leave it empty (no value after the =). This disables the default behavior where Postfix treats all domains in virtual_alias_maps as local.

Step 4: Verify and Reload

# Verify the new configuration
postconf virtual_alias_domains

# Should display:
# virtual_alias_domains =

# Verify that transport is active
postmap -q yourdomain.com hash:/var/spool/postfix/plesk/transport

# Should return:
# smtp:

# Reload Postfix
postfix reload

Step 5: Test Sending

Try sending an email from any domain on the server to the domain with external mail. It should work correctly now.

Special Cases

If the Domain is Your Master DNS Server

If the domain (e.g., merakia.es) is used as a master DNS server with subdomains like ns1.merakia.es and ns2.merakia.es, do NOT try to remove it from Plesk tables. The virtual_alias_domains = solution is correct in this case.

If You Have Multiple Domains with External Mail

Add each domain to the transport file:

echo "domain1.com smtp:" >> /var/spool/postfix/plesk/transport
echo "domain2.com smtp:" >> /var/spool/postfix/plesk/transport
echo "domain3.com smtp:" >> /var/spool/postfix/plesk/transport
postmap /var/spool/postfix/plesk/transport
postfix reload

If You Have Subdomains with Mail

If subdomains like subdomain.yourdomain.com also use external mail, add them to transport as well:

echo "subdomain.yourdomain.com smtp:" >> /var/spool/postfix/plesk/transport
postmap /var/spool/postfix/plesk/transport

Verification That It Works

After applying the changes, send a test email and check the logs:

tail -f /var/log/maillog

You should see something like:

postfix/smtp[12345]: Connecting to yourdomain-com.mail.protection.outlook.com[X.X.X.X]:25
postfix/smtp[12345]: 1234ABCD: to=<user@yourdomain.com>, relay=yourdomain-com.mail.protection.outlook.com[X.X.X.X]:25, status=sent

This confirms that Postfix is delivering mail to external servers correctly.

Troubleshooting

Domain Still Appears in Virtual Tables

This is normal and not a problem. What’s important is that virtual_alias_domains = is empty, which makes Postfix ignore those tables for routing.

Emails Get Stuck in Queue

Check the mail queue:

mailq

If there are stuck emails, verify:

  1. Connectivity to external MX servers:
    telnet yourdomain-com.mail.protection.outlook.com 25
  2. That the firewall allows outbound connections on port 25
  3. That your server is not blacklisted (RBL)

Error: “Relay access denied”

If you receive this error, verify that relay_domains is correctly configured:

postconf relay_domains

It should be empty or not include the problematic domain.

Solution Summary

The key is in two fundamental configurations:

  1. Transport maps: Tells Postfix to use external SMTP for the domain
    echo "yourdomain.com smtp:" >> /var/spool/postfix/plesk/transport
    postmap /var/spool/postfix/plesk/transport
  2. Empty virtual alias domains: Forces Postfix to query transport_maps first
    # In /etc/postfix/main.cf
    virtual_alias_domains =

With these two configurations, Postfix will stop attempting local delivery and will correctly query external MX records.

Final Configuration in main.cf

Your configuration should look like this:

# Virtual domain configuration
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
virtual_alias_domains =

# Transport maps for external domains
transport_maps = hash:/var/spool/postfix/plesk/transport

Important Notes


Applicable to: Plesk Obsidian, Postfix 3.x

 

Exit mobile version