Score:1

Postfix + Dovecot, Sieve execution flow and auto reply

in flag

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 [email protected]. Which account is aliased to devnull. My goal is recipient [email protected] silently discarded incoming mail and auto reply PONG message to sender for testing purpose. If recipient address wasn't [email protected] 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.

jp flag
Dom
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 !
jeefo avatar
in flag
Hello, Dom. I created a user named `ping` in my database as you suggested. I got response back when I sent mail to `[email protected]`. 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?
jp flag
Dom
Could you update your question with the new mail received, and the sieve/dovecot logs, please ?
jeefo avatar
in flag
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.
Score:0
in flag

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.

Score:0
uz flag

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

[email protected]   REJECT    Custom message

And do a postmap to that file

Regards

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.