2

I have a Debian server with Postfix and Dovecot. Recently I installed Sieve on Dovecot and configured Postfix to deliver emails with LMTP. Since then pure usernames don't work together with a delimiter. Delimiters only seem to get resolved when the aliases-db is involved. The log says:

User doesn't exist: [email protected] (in reply to RCPT TO command)

Here is the basic setup with some examples

username: doe  
delimiter: -    
[email protected] -> works  
[email protected] -> works  
[email protected] -> unknown user  
[email protected] -> works  

/etc/aliases :

john.doe: doe  

/etc/postfix/main.cf :

recipient_delimiter = -
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mailbox_transport = lmtp:unix:private/dovecot-lmtp
# All options: propagate_unmatched_extensions = canonical, virtual, alias, forward, include
propagate_unmatched_extensions =

1 Answer 1

4

The problem here isn't with Postfix but with Dovecot. Since Dovecot doesn't know about the Postfix recipient_delimiter it has to assume that a user query for [email protected] really does mean “Look for user »doe-test« on domain »example.com«”.

This solution to this is fortunately trivial, simply tell Dovecot what you told Postfix:

  1. Open /etc/dovecot/conf.d/15-lda.conf
  2. Uncomment the line containing #recipient_delimiter = + and replace the + by whatever (- in your case)
  3. Profit!

On Postfix address delivery and /etc/aliases:

The reason why [email protected] works in your setup is because aliases lookup is done by Postfix itself before deciding on whether the message will be delivered at all (i.e.: LMTP is not relevant at all at this stage).

So what happens is this:

  • Postfix receives a message for [email protected] using its smtpd daemon and places it in the message queue
  • The postfix qmgr daemon schedules the message for processing
  • qmgr resolves the message destination using the trivial-rewrite command
    • This is where address parsing and lookups are performed and therefor the recipient delimiter is used for the first time.
    • In particular Postfix will perform the following lookups on the aliases table:
      1. [email protected] and john.doe-test (Original address)
      2. [email protected] and john.doe (Address without adddress extension)
      3. (Possibly a few others depending on the address and configuration used.)
    • If the lookup succeeds it will return the new destination address and the message will be placed in the queue again.
  • Eventually the message will (one way or another) end up being marked as ready for delivery (even if it bounces, that's just a special type of delivery…) and qmgr will schedule the appropriate command to carry out that delivery (such as lmtp) – passing to it the message with its final delivery address (in our case [email protected])
    • If Postfix's lmtp is used for delivery a connection to the actual LMTP daemon (Dovecot) will be established and the message (with the finaly delivery address) will be passed on using the LMTP protocol.
  • Dovecot's LMTP daemon will know nothing of this whole rewriting process and will simply try to deliver the message based on the final delivery address ([email protected]) it receives.

Now, if we instead consider the case of [email protected] we see that the aliases table lookup for that address will never succeed and so the delivery address will never be rewritten. Postfix will therefor end up trying to deliver a message to [email protected] using LMTP instead.

Shouldn't Postfix just discard the address extension before trying to deliver using LMTP?
Maybe, but not discarding it comes with a huge benefit: Dovecot will be able to know about the address extension. This may not seem very useful, but processing the address extension on the Dovecot side allows for cool things such as automatically placing messages in IMAP sub-folders using Sieve.

2
  • Hi, it works like a charm. I'm still confused, why the problem only occurs with pure usernames and not with items in the alias list, but telling dovecot about the delimiter makes sense anyways.
    – jochen
    Oct 6, 2017 at 6:49
  • @jochen: I've updated my answer to explain how delivery works in Postfix and why it failed when using address extensions, but now aliases in your case.
    – ntninja
    Oct 7, 2017 at 11:23

You must log in to answer this question.

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