0

I'm trying to setup a mail service on my server with this and this articles.

After finishing configuration, i got working user accounts - its possible to successfully login on each account with Thunderbird, manage folders etc. I can send email from one account to another without error (at least on client side) - but they can not be delivered. In mail.log i have:

Aug 31 13:03:46 serwer postfix/virtual[3516]: 4DCB1E132A: to=<[email protected]>, relay=virtual, delay=2117, delays=2117/0.01/0/0.01, dsn=4.2.0, status=deferred (delivery failed to mailbox /home/vmail/%d/%n/1: unable to create lock file /home/vmail/%d/%n/1.lock: No such file or directory)

Of course domain is different, just replaced it now to hide real one. As i was searching on web for solutions i noticed that in other similar log entries, path to maildir is full resolved, like:

/home/vmail/example.com/admin/1.lock

In my logs its still with %d and %n - is this a problem?

Postfix conf:

smtpd_tls_cert_file=/etc/postfix/ssl/smtpd.cert
smtpd_tls_key_file=/etc/postfix/ssl/smtpd.key
smtpd_use_tls=yes
smtpd_tls_auth_only=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_sasl_type=dovecot
smtpd_sasl_path=private/auth
smtpd_sasl_auth_enable=yes
smtpd_recipient_restrictions=permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
virtual_mailbox_base=/home/vmail/%d/%n
virtual_mailbox_domains=mysql:/etc/postfix/mysql-domains.cf
virtual_mailbox_maps=mysql:/etc/postfix/mysql-maps.cf
virtual_alias_maps=mysql:/etc/postfix/mysql-alias.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
local_recipient_maps = $virtual_mailbox_maps

1 Answer 1

3

You're not using the virtual_mailbox_base parameter like you're supposed to.

A prefix that the virtual(8) delivery agent prepends to all pathname results from $virtual_mailbox_maps table lookups. This is a safety measure to ensure that an out of control map doesn't litter the file system with mailboxes.

This is only a safety measure and isn't designed to indicate where the email should be delivered. That is the job of virtual_mailbox_maps.

You should instead set it to virtual_mailbox_base = /home/vmail and have your MySQL query from virtual_mailbox_maps returning a relative path to the users's mailbox directory, like "domain.com/username" which would then become "/home/vmail/domain.com/username" once prepended with the virtual_mailbox_base.

3
  • 1
    PS: most tutorials out there are bullshit and merely copy/paste other (older) tutorials with no concerns for performance or security. Rather than wasting your time with them, why don't you read the official Postfix documentation ? Also, do you really need MySQL ? Unless you have 100 accounts or more, a text file would give better performance and lower your attack surface & complexity. Aug 31, 2015 at 13:14
  • Well, 100 accounts definitely not, but 100 aliases? Sure, or even more. (like individual email address for each website where i have account, all pointing to single email account) Maybe its a good idea to keep accounts in a file, ill think about it.
    – WombaT
    Aug 31, 2015 at 13:41
  • @WombaT if you just need an alias like username-*anything*@domain.com you can set recipient_delimiter = - and the single alias username will work for any username-***anything***@domain.com address. Aug 31, 2015 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .