1

I'm using Postfix and Dovecot LMTP on my server. My question is how do I create a silently discarding recipient address and respond auto reply? Also I want to learn Postfix and Dovecot execution control flow. This is part of my Postfix main.cf:

alias_maps = hash:/etc/aliases

# Virtual domains
virtual_uid_maps        = static:5000
virtual_gid_maps        = static:5000
virtual_minimum_uid     = 115
virtual_mailbox_base    = /home/vmail
virtual_mailbox_maps    = mysql:/etc/postfix/mysql/mailbox.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/domains.cf
virtual_alias_maps      = mysql:/etc/postfix/mysql/aliases.cf
virtual_transport       = lmtp:unix:private/dovecot-lmtp

In my /etc/aliases:

devnull: /dev/null

In my humble understanding Postfix handles recipient address exists or not right? If recipient address was existed then transport to Dovecot LMTP to handle local delivery. Is it possible to conditional transport in Postfix? For example I want to create a test mail address such as ping@example.com. Which account is aliased to devnull. My goal is recipient ping@example.com silently discarded incoming mail and auto reply PONG message to sender for testing purpose. If recipient address wasn't ping@example.com then transport to Dovecot-lmtp. I tried to use Dovecot Sieve filter plugin with vacation extension to handle auto reply. But in my system's mail.log:

# replaced actual domain name with DOMAIN

postfix/lmtp[13532]: 62EBD333697: to=<devnull@DOMAIN>, orig_to=<ping@DOMAIN>, relay=DOMAIN[private/dovecot-lmtp], delay=538, delays=538/0.02/0.01/0.44, dsn=5.1.1, status=bounced (host DOMAIN[private/dovecot-lmtp] said:
 550 5.1.1 <devnull@DOMAIN> User doesn't exist: devnull@DOMAIN (in reply to RCPT TO command))

So, I guess Dovecot Sieve filter plugin doens't work with account which doesn't exist. Is it possible to execute Sieve script before checking user's mailbox? If so I don't even need to use devnull blackhole alias. I can do that in my sieve script something like this:

if address :matches "To" "ping@*" {
    vacation
        :seconds 1
        "PONG";
    discard;
}

UPDATED:

I created a user named ping in my database and I got a response mail in my GMail account. But it wasn't really a reply mail. It was a new mail in my inbox. Then I tried to manually reply using Apple mail GUI software. It works as expected. Then I go to gmail and press on menu show original.

From Apple Mail's message-id domain part was correct virtual domain of sender. From Apple mail

But from Dovecot/Sieve's message-id domain part was my server's hostname. From sieve vacation

I don't know why it happens. But my guess is maybe it's because domain name was changed? In working example from Apple Mail software it was correct virtual domain of sender. But from sieve auto-reply it was changed my server's real hostname.

Another Postfix log from /var/log/mail.log

postfix/cleanup[1329]: EE83F333699: message-id=<dovecot-sieve-1623257247-953496-0@HOSTNAME>

PS: I have only few days experience with Postfix, Dovecot and few hours experience with sieve script. I'm so newbie. I hope my question and goal was clear enough. Ask me anything if you need more information.

jeefo
  • 11
  • 4
  • The Sieve is used only when the user exists for Postfix AND Dovecot. Apparently, your Dovecot don't know the user. You have correctely defined the Sieve rule, so create the user (or configure Dovecot to use the same DB as postfix) : it will accept the mail, answer the vacation and discard the mail. Look at the sieve logs too ! – Dom Jun 08 '21 at 15:10
  • Hello, Dom. I created a user named `ping` in my database as you suggested. I got response back when I sent mail to `ping@mydomain.ltd`. But my response mail wasn't really reply mail. It was actually new mail in my inbox. How can I achieve actual reply using sieve vacation? – jeefo Jun 08 '21 at 16:37
  • Could you update your question with the new mail received, and the sieve/dovecot logs, please ? – Dom Jun 09 '21 at 05:24
  • Sorry, I haven't any log file for Sieve. Didn't find how to log it at the time. For Dovecot I tried to find useful logs executing `sudo doveadm log find` command. Most of logs was pointed to `/var/log/mail.log`. And there wasn't any any useful logs. BTW I updated my question for more information. Thank you. – jeefo Jun 09 '21 at 17:48

2 Answers2

0

Why you don't use postfix custom replies? I'm not sure if the message ID will be changed or not, but try it.

On main.cf, smtpd_recipient_restrictions configure

 check_recipient_access hash:/path/custom_replies

Then on /path/custom_replies

ping@example.com   REJECT    Custom message

And do a postmap to that file

Regards

Gontzal
  • 21
  • 4
0

I fixed it by adding "Re: " abbreviation before Subject string. Seems like GMail create a new conversation history if Subject is changed.

Message-id wasn't the problem. Also I didn't use Sieve vacation plugin to reply. Instead sieve_extprograms plugin and pipe it to shell script then curl post to my NodeJS server.

jeefo
  • 11
  • 4