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

  • Plesk Server: Manages hosting and DNS for domain.com
  • External Mail: Office 365/Outlook handles mailboxes for domain.com
  • Problem: Other domains on the same Plesk cannot send emails to domain.com
  • Cause: Postfix attempts local delivery instead of querying external MX records

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

  • ✅ This configuration does NOT affect other domains with mail in Plesk
  • ✅ You do NOT need to remove the domain from Plesk
  • ✅ Domain hosting and DNS continue working normally
  • ✅ Only changes the behavior of mail routing
  • ⚠️ Make sure to backup main.cf before modifying it

Applicable to: Plesk Obsidian, Postfix 3.x

 

Expertos en Diseño, Comunicación y Programación

En Carlos Herrera somos expertos en Diseño Gráfico, Marketing Digital  y programación. Si estás pensando en actualizar tu marca, necesitas desarrollar tu imagen corporativa o tu web somos lo que buscas. Nos encontramos en Santander, Cantabria pero trabajamos para clientes de todo el mundo. Contacta con nosotros, estaremos encantados de asesorarte.

Previous Post
PHP 8.5 vs PHP 8.2: clear differences… in case you’re still hesitating
ARTÍCULOS RELACIONADOS
¿Quieres tranquilidad y rendimiento para tu sitio WordPress?

Optimiza tu web con nuestro servicio de mantenimiento especializado. Deja de preocuparte por caídas, errores y malfuncionamientos.

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Skip to content