What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Host several domains on one Postfix server by assigning each domain to a Postfix virtual-domain class, then defining how recipients are resolved. Use virtual_alias_domains when addresses should forward to local UNIX accounts or remote addresses. Use virtual_mailbox_domains when each address needs its own mailbox, whether Postfix delivers locally or hands mail to an LMTP or other mailbox service.

The reliable sequence is: point DNS for every domain at the intended mail system, declare each domain in exactly one destination class, maintain the appropriate recipient map, rebuild file-backed maps with postmap, reload Postfix, and test both valid and unknown recipients. Keeping hosted domains out of mydestination prevents many relay and looping errors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Postfix classifies multiple domains

Postfix decides whether it is responsible for a recipient domain by checking destination classes. A domain can be treated as a final destination when it matches mydestination, a local or proxy interface, virtual_alias_domains, or virtual_mailbox_domains. These classes are not interchangeable.

  • mydestination: canonical names for the mail server and domains whose recipients are local system accounts. It is not the place for ordinary virtual hosting.
  • virtual_alias_domains: domains whose addresses are looked up in a virtual-alias map and rewritten to another address.
  • virtual_mailbox_domains: domains with explicitly managed virtual recipients and mailbox locations.

Declare a hosted domain in the class that owns its recipient data. Putting a virtual-alias domain in mydestination is specifically discouraged in Postfix documentation because it changes the address class and can bypass the virtual alias lookup. Declaring the same domain in competing classes also creates ambiguous behavior. Keep the lists deliberate and non-overlapping.

Choose aliases or mailboxes before editing configuration

Question Virtual aliases Virtual mailboxes
What does an address represent? An alias that rewrites an envelope recipient to one or more local or remote recipients. An independently managed mailbox recipient with a path or a delegated delivery service.
Typical delivery UNIX-account delivery or forwarding to another address. Direct virtual delivery, or handoff through virtual_transport to LMTP or another mailbox service.
Recipient map key Usually a complete address such as info@example.com; domain-wide and catch-all patterns are also possible but require care. The complete address, mapped to a mailbox-relative path such as example.com/info.
Best fit Role addresses, forwarding, shared destinations, and a small number of aliases. Separate inboxes for users or applications, with independent storage and recipient acceptance.
Unknown-recipient control Only addresses represented by the alias policy should be accepted; broad catch-alls can create abuse. The mailbox map acts as the recipient-acceptance list unless another policy deliberately broadens it.
Data back end Flat files, SQL, LDAP, or another supported Postfix map type. Flat files, SQL, LDAP, or another map, plus a mailbox store when delivery is delegated.

Some installations use both classes: a domain can have virtual mailboxes for user accounts and aliases for role addresses, provided the configuration follows the selected delivery design and does not place the domain in an unrelated destination class.

Prerequisites and a safe preparation checklist

  • Administrative access to the Postfix host and permission to edit /etc/postfix/main.cf and any map files.
  • DNS MX records for every hosted domain pointing to this server or to the front end that will pass mail to it. Confirm that the A or AAAA records used by those MX targets are reachable.
  • A decision about storage: local UNIX accounts, Postfix’s virtual delivery agent, or an external mailbox service reached through LMTP or a configured pipe.
  • A recipient data source. The examples below use LMDB files; SQL, LDAP, and other map types can be substituted when their map configuration is installed.
  • A non-production test address and a deliberately invalid address for each domain.

Back up the current configuration and record the output of postconf -n before changing it. That snapshot makes it easier to identify an accidental overlap or restore the previous behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Option A: configure virtual alias domains

Virtual aliases rewrite envelope recipients. They are separate from the traditional aliases(5) table: the traditional table applies only after a recipient is treated as local, while the virtual alias mechanism applies to envelope recipients in a virtual alias domain.

1. Declare the hosted alias domains and map

virtual_alias_domains = example.com example.net
virtual_alias_maps = lmdb:/etc/postfix/virtual

Replace the domain names with the complete set of alias-only domains. Do not add those domains to mydestination. If the list is long, maintain it in a form appropriate to your configuration management, but ensure the resulting Postfix parameter contains the intended domains.

2. Create recipient mappings

postmaster@example.com postmaster
info@example.com       joe
sales@example.net      jane@remote.example

The left column is the incoming envelope address. The right column can be a local UNIX account, another local address, or a remote address. A local target such as joe is resolved through local delivery rules; a fully qualified remote target is routed according to normal Postfix transport and relay policy.

3. Build the indexed map and reload

postmap /etc/postfix/virtual
postfix reload

postmap reads the source file and creates the indexed database used by the lmdb: map declaration. Editing the source without rebuilding the index leaves Postfix using stale data. A reload makes the running service reread configuration without requiring a full stop and start.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Decide how unknown addresses behave

List only the addresses you intend to receive. A catch-all alias can accept every address at a domain, but Postfix’s virtual-domain guidance warns that this commonly attracts spam and backscatter for forged recipients. If a catch-all is unavoidable, understand that accepting mail first and discovering later that the apparent recipient was forged shifts the abuse and bounce burden onto your server.

Option B: configure virtual mailbox domains

Use virtual mailboxes when recipients need separate inboxes rather than simple rewrites. The following direct-delivery example follows Postfix’s documented layout, with a common base directory and static ownership identifiers.

1. Declare domains, storage, and recipient maps

virtual_mailbox_domains = example.com example.net
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_alias_maps = lmdb:/etc/postfix/virtual

The UID and GID values are examples from the documented pattern, not a universal account choice. Verify that the corresponding user and group exist, that the numeric IDs meet your host’s policy, and that the mail base directory has ownership and permissions consistent with those IDs. Never copy an ownership number blindly onto a system where it maps to an unintended account.

2. Map each complete address to a mailbox path

info@example.com  example.com/info
sales@example.net  example.net/sales/

The values are relative to virtual_mailbox_base. Thus, the first entry resolves below /var/mail/vhosts/example.com/info, while the second uses a path ending in a slash as shown. Create the required directory structure and make sure the delivery identity can write to it. The exact mailbox format and directory contents depend on the virtual delivery agent and the rest of your mail stack.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Build the map and reload

postmap /etc/postfix/vmailbox
postfix reload

Run postmap every time the file-backed source changes. If you also maintain aliases in /etc/postfix/virtual, rebuild that map separately.

4. Delegate delivery to another mailbox store when needed

Postfix does not require the virtual(8) delivery agent to be the final mailbox writer. If an IMAP server or another mailbox service owns storage, configure virtual_transport for the LMTP client or a service defined in master.cf. Keep the virtual mailbox map as the recipient-acceptance layer so Postfix can reject unknown users during SMTP, then hand accepted messages to the service that owns the mailbox format.

Using aliases with virtual mailboxes

A mailbox domain often needs role addresses such as postmaster@example.com in addition to individual user mailboxes. Keep those mappings in the virtual alias map and make the target an address that your mailbox design can deliver. For example, an alias may target a real virtual mailbox address or a local account, depending on the rest of the routing configuration.

Do not assume that adding a domain to virtual_mailbox_domains automatically creates every possible address. The mailbox map still needs an entry for each recipient you intend to accept. Likewise, an alias entry does not create a physical mailbox unless its target ultimately resolves to one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Activation and verification procedure

  1. Verify DNS: query the MX records for each hosted domain and confirm that the advertised destination is the server or front end that should receive mail. Check both domains independently; a correct MX for one does not configure the other.
  2. Inspect destination classes: run postconf mydestination virtual_alias_domains virtual_mailbox_domains. Remove hosted virtual domains from mydestination and ensure each appears in the intended virtual list.
  3. Edit source maps: change /etc/postfix/virtual, /etc/postfix/vmailbox, or the configured SQL or LDAP data source. Keep one canonical record for every recipient.
  4. Test representative lookups: for file-backed maps, run commands such as postmap -q info@example.com lmdb:/etc/postfix/virtual or postmap -q info@example.com lmdb:/etc/postfix/vmailbox. The returned value should be the expected target or mailbox path.
  5. Rebuild indexes: run postmap against every changed file-backed source.
  6. Validate syntax and service state: run postfix check, inspect postconf -n, and correct warnings before reloading.
  7. Reload: run postfix reload after changes to main.cf, master.cf, or map data that requires a new index.
  8. Send controlled tests: deliver one message to a valid recipient in every hosted domain and one message to an intentionally invalid recipient. Confirm the valid message reaches the expected mailbox or forward target and that the invalid address is rejected or handled according to your policy.
  9. Read the logs and queue: correlate the test time with Postfix mail logs and inspect queue status. Follow the message through recipient lookup, transport selection, delivery, and any remote forwarding hop.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why mail to a second domain is rejected or loops

“Relay access denied” or a relay rejection

The domain is often missing from both virtual-domain parameters, or it is being treated as an outbound relay destination rather than a final destination. Check the exact spelling in virtual_alias_domains or virtual_mailbox_domains, verify that DNS points to this host, and inspect restrictions that may apply before recipient classification.

Mail loops back to the server

A common cause is putting a virtual domain in mydestination or otherwise assigning it to the wrong address class. Remove the overlap, reload, and retest. Also check that an alias target is not rewriting to an address that routes back to the same alias indefinitely.

Best Value
Forvencer Server Book, 2 Zipper Pocket, Server Books for Waitress
  • Upgraded Two Zipper Pockets: Forvencer server books feature two secure zipper pockets for better organization of coins, cash, and receipts, ensuring that everything you collect has a safe and secure place
  • Smart Storage & Quick Access: Designed with 8 multi-functional compartments, the right side includes a guest receipt pad, while the left has a money pocket, ticket pocket, and credit card slot. Two small clear pockets store bills, receipts, and other visible items. A stitched pen loop ensures you always have your favorite pen ready
  • High-quality & Easy to Clean: Crafted from high-quality PU leather with heavy-duty stitching, this server book is built to last. It resists tears, scratches, and its waterproof surface makes cleaning easy with just a damp cloth or a non-chlorine sanitizer
  • Perfect Fit for Your Apron: Measuring 5” x 8”, this compact organizer is slightly smaller than other models, making it ideal for bending or sitting while carrying in your server apron. It holds everything a waitress needs—a place for everything
  • What's Included: This server organizer comes with multiple open and zippered pockets to store money, receipts, tips, etc. Clear sleeves are perfect for keeping menus or special lists while serving. Available in a variety of colors, allowing you to express yourself even when in uniform

“User unknown” for an address that should work

The domain may be declared correctly while the individual recipient is absent from the map. Query the map with postmap -q, check capitalization and spelling, rebuild the index, and reload if required. For virtual mailboxes, verify that the key is the full address and that the path value is valid relative to virtual_mailbox_base.

Configuration changes appear to do nothing

Check that you edited the file Postfix actually reads, that a map index was rebuilt after the source changed, and that postfix reload completed successfully. Use postconf -n to detect a value overridden elsewhere or a typo in the parameter name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Valid mail is accepted but never reaches the inbox

For direct virtual delivery, inspect directory ownership, permissions, UID and GID mappings, and the mailbox path. For delegated delivery, inspect the LMTP client or master.cf service, its socket or endpoint, and the service’s own logs. Acceptance at SMTP proves only that Postfix recognized the recipient; it does not prove final mailbox delivery.

Operational boundaries: what this setup does not provide

Virtual aliasing and virtual mailbox configuration solve recipient classification and delivery routing. They do not automatically choose a TLS certificate, publish SPF records, sign DKIM, enforce a DMARC policy, select a DNS provider, or provide a mailbox application. Those are separate deployment decisions that must match the domains, transports, and services in use.

Forwarding deserves additional attention. A virtual alias rewrites the envelope recipient; it does not by itself preserve authentication results or guarantee that a forwarded message will pass the receiving domain’s SPF, DKIM, or DMARC checks. Design forwarding behavior and outbound authentication separately, especially when forwarding to unrelated remote domains.

Apply least privilege to map files and mailbox directories, monitor queue growth, and retain logs long enough to diagnose recipient and transport failures. Keep catch-all behavior disabled unless there is a documented business reason and an abuse-control plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Maintenance checklist for additional domains

  • Add the domain to exactly one appropriate virtual destination class.
  • Publish and verify its MX records before accepting production traffic.
  • Add every required recipient to the alias or mailbox data source.
  • Run postmap for each changed file-backed map.
  • Run postfix check and review postconf -n for overlap.
  • Reload Postfix after configuration changes.
  • Test a known recipient, an unknown recipient, and any forwarding or LMTP path.
  • Record the domain’s mailbox owner, map source, transport, and operational contact so future changes do not rely on guesswork.

Decision guide

Choose virtual aliases when the central requirement is “receive this address and send it to that account,” whether the destination is local or remote. Choose virtual mailboxes when every address needs an independent inbox and recipient existence must be tied to mailbox records. If mailbox storage belongs to another service, still use the virtual mailbox map to define accepted recipients and configure a transport that hands delivery to that service. In all cases, the domain declaration, recipient map, map index, reload, and end-to-end tests must agree.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.