Postfix virtual everything

So I’m trying to get postfix to keep everything it gets sent and just store it in a file/database, whatever, for later processing. This falls under the category of not destined for existing user accounts, which means that neither the normal method of sending (directly to a Linux user account), or virtual aliasing (to a Linux user account) of a different name really work. I guess I could virtual alias everything to some user account, but if I’m only using one destination name per email, I’m not really sure there’s any difference at all between virtual aliasing and virtual mailboxes. So here’s my


smtpd_banner = $myhostname ESMTP $mail_name
biff = no

# appending .domain is NOT postfix's concern:
append_dot_mydomain = no

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, reject

# Remove some defaults:
#myhostname = # uses `hostname`, so no need to set it here
#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
#myorigin = /etc/mailname

# Note that is not in my "mydestination" list
mydestination =,, localhost

mynetworks = [::ffff:]/104 [::1]/128

# I'm not sure this has any effect in the virtual mailbox, so my default is empty
recipient_delimiter = +

virtual_alias_maps =
#virtual_alias_domains = # defaults to virtual_alias_maps, so no need to set it.

# *** Here's the good part ***
virtual_mailbox_domains =
# Prereq: make sure "/var/mail/vhosts" exists
virtual_mailbox_base = /var/mail/vhosts
# /etc/postfix/virtual is shown below:
virtual_mailbox_maps = hash:/etc/postfix/virtual
# run `id` to get these values for whatever user you want to own the mailbox file.
# the "static:" prefix is just to say it's the actual value, and not a map's filename
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
# no size limit (usually it's 51.2 MB)
virtual_mailbox_limit = 0


Because I put there, you must also ensure the directory /var/mail/vhosts/ exists and belongs to 1000:1000.

Also, as with any hash:* referenced postfix (mapping) file, you must run sudo postmap /etc/postfix/virtual (which created /etc/postfix/virtual.db) and then sudo postfix reload to tell postfix to reload its config.