Postfix SMTP Error: “Sender Address Rejected – User Unknown in Virtual Mailbox Table” – Full Fix Guide


2 views

When configuring SMTP in your application, you might encounter this Postfix rejection with error code 550:

SMTPRecipientsRefused: {
  'recipient@domain.com': (550, '5.1.0 <sender@domain.com>: Sender address rejected: User unknown in virtual mailbox table')
}

This occurs when Postfix cannot verify the sender address in its virtual mailbox table. Let's break down what's happening in the mail server logs:

postfix/smtpd[30281]: NOQUEUE: reject: RCPT from unknown[xx.xx.xx.xx]: 
550 5.1.0 <sender@domain.com>: Sender address rejected: 
User unknown in virtual mailbox table

This typically happens in these configurations:

  • Using bounce addresses with non-existent sender domains
  • Misconfigured virtual mailbox maps
  • Missing sender address verification in Postfix
  • Incorrect return-path settings in your application

First, ensure your application uses a valid sender address that exists in Postfix's virtual mailbox table. Here's a Python example of proper SMTP configuration:

import smtplib

smtp_server = 'mail.yourdomain.com'
smtp_port = 587
username = 'valid_user@yourdomain.com'  # Must exist in Postfix
password = 'yourpassword'

server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(username, password)

msg = """From: valid_user@yourdomain.com
To: recipient@gmail.com
Subject: Test Email

This is a test message.
"""

server.sendmail('valid_user@yourdomain.com', 'recipient@gmail.com', msg)
server.quit()

If you control the Postfix server, make these adjustments in main.cf:

# For testing only - allows any sender (not recommended for production)
smtpd_sender_restrictions = permit_mynetworks, reject_unknown_sender_domain

# Proper virtual mailbox configuration
virtual_mailbox_domains = hash:/etc/postfix/virtual_domains
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailboxes

# After making changes, update maps
sudo postmap /etc/postfix/virtual_domains
sudo postmap /etc/postfix/virtual_mailboxes
sudo systemctl reload postfix

If you're using bounce addresses (common in mailing systems), ensure they're properly configured:

# In your application configuration:
bounce_address = "bounces+{UNIQUE_ID}@yourdomain.com"

# Then in Postfix virtual_mailboxes:
bounces@yourdomain.com  whatever/file/path

When troubleshooting, use these Postfix commands:

# Check if sender domain exists in virtual domains
postmap -q yourdomain.com /etc/postfix/virtual_domains

# Check if sender address exists in virtual mailboxes
postmap -q user@yourdomain.com /etc/postfix/virtual_mailboxes

# Verify Postfix configuration
postconf -n | grep virtual_
postconf -n | grep sender

html

When configuring an SMTP client to send emails through a Postfix mail server, you might encounter the error:

SMTPRecipientsRefused: {'recipient@example.com': (550, '5.1.0 <sender@domain.com>: Sender address rejected: User unknown in virtual mailbox table')}

This occurs when Postfix cannot verify the sender address in its virtual mailbox table. The mail server logs typically show:

postfix/smtpd[XXXXX]: NOQUEUE: reject: RCPT from unknown[IP]: 550 5.1.0 <sender@domain.com>: Sender address rejected: User unknown in virtual mailbox table

The error appears because:

  • The sender address (MAIL FROM) doesn't exist in Postfix's virtual mailbox table
  • Your Postfix configuration enforces strict sender verification (reject_unverified_sender)
  • The virtual mailbox map (virtual_mailbox_maps) isn't properly configured

First, examine your Postfix main.cf:

postconf -n | grep -E 'virtual_mailbox_maps|reject_unverified_sender'

Typical output might show:

virtual_mailbox_maps = hash:/etc/postfix/virtual_mailbox
smtpd_reject_unverified_sender = yes

Here's how to resolve this:

Option 1: Add Sender to Virtual Mailbox Table

Edit your virtual mailbox map file (e.g., /etc/postfix/virtual_mailbox):

sender@domain.com   domain.com/sender/

Then rebuild the map:

postmap /etc/postfix/virtual_mailbox
systemctl reload postfix

Option 2: Disable Sender Verification (Not Recommended)

If you must bypass verification temporarily:

postconf -e "smtpd_reject_unverified_sender=no"
systemctl reload postfix

Use this Python script to test your SMTP configuration:

import smtplib

try:
    with smtplib.SMTP('your.mail.server', 25) as smtp:
        smtp.login('username', 'password')
        smtp.sendmail(
            'verified_sender@domain.com',  # Must match virtual mailbox
            'recipient@example.com',
            'Subject: Test\n\nThis is a test message'
        )
    print("Email sent successfully")
except Exception as e:
    print(f"Error: {e}")

For production systems, consider these additional measures:

# In main.cf:
smtpd_sender_restrictions = 
    reject_unknown_sender_domain,
    reject_unverified_sender,
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination

Use these commands to troubleshoot:

# Check if sender exists in virtual mailbox
postmap -q "sender@domain.com" /etc/postfix/virtual_mailbox

# Monitor Postfix logs in real-time
tail -f /var/log/mail.log | grep postfix/smtpd
  • Forgetting to run postmap after editing virtual mailbox files
  • Mismatched domain in sender address and virtual mailbox
  • Incorrect file permissions on virtual mailbox maps