dovecot with sieve vacation plugin
Hi all
I have an issue understanding the sieve vacation plugin. I can get it trigger for particular emails or something, but I don't get the sender setting right.
My setup:
I've got an external email address a@aaa.com and a local b@bbb.local (which is used in virtual_mailbox_maps in postfix or for user authentication in dovecot). Emails for a@aaa.com get stored in the b@bbb.local mailbox.
Postfix uses an external relay to transfer emails from a@aaa.com. Sending and receiving emails works as a charm.
In received emails I see headers for
Return-Path: <the original sender> Delivered-To: b@bbb.local Envelope-To: a@aaa.com X-Original-to: a@aaa.com
In sieve I've got configured for the user b@bbb.local
require "vacation"; if allof ( address :domain "From" "other-sender.com", currentdate :value "ge" "date" "2023-05-24" ) { vacation :from "a <a@aaa.com>" #:addresses ["a@aaa.com", "b@bbb.local"] :addresses ["a@aaa.com"] :subject "Out of office by EoL" "bla bla bla"; }
The issue:
When I receive an email from e. g. john@other-sender.com a vacation response gets created and sent. The From header ist set to the value configured by ":addresses ["a@aaa.com"]". But:
a) If I set "sieve_vacation_send_from_recipient = yes" in dovecot.conf the sender header in the vaction response is filled in with b@bbb.local.
b) If I set "sieve_vacation_send_from_recipient = no" in dovecot.conf the sender header in the vaction response stays blank (which I understand is the preferred way).
Different settings for sieve_vacation_use_original_recipient don't seem to make any difference.
In both cases a) and b) postfix tries todeliver the email directly to the receiving mail server and does not care for my sender relay host map (sender_dependent_relayhost_maps in postfix main.cf), well of course as there is no relay host for @bbb.local (case a)) and in case b) the sender is blank.
In my understanding the vacation plugin uses the original recipient as sender for the out of office reply which in my case is in the X-Original-to header (I use lmtp and have also set "lda_original_recipient_header = X-Original-To"). But it does not - it sticks with the b@bbb.local mail address as sender. If I omitted the sender setting - how could I tell postfix to relay these ooo mails through the correct relay (like based on the From header domain in the vacation response)?
What would the right approach be to set the sender right or get postfix to relay the vacation responses correctly?
Any help would be appreciated!
-- Cheers spi
In my understanding the vacation plugin uses the original recipient as sender for the out of office reply which in my case is in the X-Original-to header (I use lmtp and have also set "lda_original_recipient_header = X-Original-To"). But it does not - it sticks with the b@bbb.local mail address as sender. If I omitted the sender setting - how could I tell postfix to relay these ooo mails through the correct relay (like based on the From header domain in the vacation response)?
What would the right approach be to set the sender right or get postfix to relay the vacation responses correctly?
I did some more digging in my "mail process chain":
incoming mail --> postfix (*) --> milter --> postfix --> lmtp/dovecot --> sieve
postfix (*) presents the right "rcpt to a@aaa.com" to the milter filter, but sieve only sees the internal b@bbb.local. I expected the sieve vacation module to interpret the X-Original-to header but it seems to not do that (my idea was to circumvent that way the issue with postfix and lmtp to not forward the right "rcpt to" information).
Is there a way to get the vacation module respect the X-Original-to header? Or any other approch to get that working with lmtp (and not switching back to lda)?
-- Cheers spi
postfix (*) presents the right "rcpt to a@aaa.com" to the milter filter, but sieve only sees the internal b@bbb.local.
Why convert/alias a@aaa.com to b@bbb.local? Why not setup dovecot to have a mailbox and receive mail for a@aaa.com, allowing sieve to run for a@aaa.com, and users login as a@aaa.com on IMAP to check their mail?
Am 09.06.23 um 20:13 schrieb dovecot--- via dovecot:
postfix (*) presents the right "rcpt to a@aaa.com" to the milter filter, but sieve only sees the internal b@bbb.local.
Why convert/alias a@aaa.com to b@bbb.local? Why not setup dovecot to have a mailbox and receive mail for a@aaa.com, allowing sieve to run for a@aaa.com, and users login as a@aaa.com on IMAP to check their mail?
That would work if users only had one alias, but they don't - they have several aliases.
-- Cheers spi
Why convert/alias a@aaa.com to b@bbb.local? Why not setup dovecot to have a mailbox and receive mail for a@aaa.com, allowing sieve to run for a@aaa.com, and users login as a@aaa.com on IMAP to check their mail?
That would work if users only had one alias, but they don't - they have several aliases.
Just to make sure that the vacation plugin works at all I set up a new user with just one mail address x@aaa.com. Vacation replies get sent as long "sieve_vacation_send_from_recipient = yes" is configured in dovecot.conf (my postfix uses different relay hosts).
As said I can't just change users' mail addresses to external ones as they are using several aliases. And I would prefer to use "sieve_vacation_send_from_recipient = no" (due to bounces). I wonder if there is a way to tell postfix to choose a relay host for the vacation replies based on the From: address (which is set by the sieve vacation plugin) rather than the "mail from" address.
-- Cheers spi
Why convert/alias a@aaa.com to b@bbb.local? Why not setup dovecot to have a mailbox and receive mail for a@aaa.com, allowing sieve to run for a@aaa.com, and users login as a@aaa.com on IMAP to check their mail?
That would work if users only had one alias, but they don't - they have several aliases.
On my system i am using virtual accounts in postfix with virtual_mailbox_maps. For user alias im using postfix virtual_alias_maps.
user@example.com is a mailbox someone can login to IMAP with. They have alias@example.com -> user@example.com with the alias map.
If someone sends an email to alias@example.com it ends up in the user@example.com inbox via LMTP
Jun 10 13:38:23 postfix/lmtp[1953783]: 4QdlXt4pn1z7Vv0h: to=<user@example.com>, orig_to=<alias@example.com>, relay=smtp.example.com[private/dovecot-lmtp], delay=2.1, delays=1.7/0.01/0/0.44, dsn=2.0.0, status=sent (250 2.0.0 <user@example.com> N9ypKw61hGTzxB0AbpFOwA Saved)
For sieve plugin i have in dovecot.conf:
sieve_vacation_use_original_recipient = no sieve_vacation_dont_check_recipient = no sieve_vacation_send_from_recipient = no sieve_redirect_envelope_from = sender sieve_user_email = %u
And as a sieve rule i have:
require ["vacation"]; # rule:[Out of Office] if true { vacation :days 1 :addresses ["user@example.com","alias@example.com"] :subject "TEST - Out of Office" "This is a test reply for the out of office auto responder."; }
This works for me. If someone sends an email to alias@example.com they will receive an auto reply with the From: header as alias@example.com and the envelope-from as <> which end users wont see.
Why convert/alias a@aaa.com to b@bbb.local? Why not setup dovecot to have a mailbox and receive mail for a@aaa.com, allowing sieve to run for a@aaa.com, and users login as a@aaa.com on IMAP to check their mail?
That would work if users only had one alias, but they don't - they have several aliases.
On my system i am using virtual accounts in postfix with virtual_mailbox_maps. For user alias im using postfix virtual_alias_maps.
user@example.com is a mailbox someone can login to IMAP with. They have alias@example.com -> user@example.com with the alias map.
If someone sends an email to alias@example.com it ends up in the user@example.com inbox via LMTP
Jun 10 13:38:23 postfix/lmtp[1953783]: 4QdlXt4pn1z7Vv0h: to=<user@example.com>, orig_to=<alias@example.com>, relay=smtp.example.com[private/dovecot-lmtp], delay=2.1, delays=1.7/0.01/0/0.44, dsn=2.0.0, status=sent (250 2.0.0 <user@example.com> N9ypKw61hGTzxB0AbpFOwA Saved)
For sieve plugin i have in dovecot.conf:
sieve_vacation_use_original_recipient = no sieve_vacation_dont_check_recipient = no sieve_vacation_send_from_recipient = no sieve_redirect_envelope_from = sender sieve_user_email = %u
And as a sieve rule i have:
require ["vacation"]; # rule:[Out of Office] if true { vacation :days 1 :addresses ["user@example.com","alias@example.com"] :subject "TEST - Out of Office" "This is a test reply for the out of office auto responder."; }
This works for me. If someone sends an email to alias@example.com they will receive an auto reply with the From: header as alias@example.com and the envelope-from as <> which end users wont see.
Thanks, tried you settings and they are almost the same I am using too, but:
"sieve_user_email = %u" creates a warning: "Warning: sieve: Invalid address value for setting `sieve_user_email': Missing domain"
Still - I see vacation replies created, the issue though is that I am using different relay hosts and whatever "sieve_vacation_send_from_recipient" ist set to, postfix tries to deliver the mail directly to the receiving MX and does not respect my relay hosts.
What I am currently trying to figure out is, is there a way to tell postfix in case it is a vacation reply with no envelope to but a valid from header use that from header as a rule for choosing the right relay host.
-- Cheers spi
- "sieve_user_email = %u" creates a warning: "Warning: sieve: Invalid address value for setting `sieve_user_email': Missing domain"
That warning is a glitch, ignore it. I mentioned it on the list before but has not been fixed in any of the updates.
What I am currently trying to figure out is, is there a way to tell postfix in case it is a vacation reply with no envelope to but a valid from header use that from header as a rule for choosing the right relay host.
I don't think postfix knows how or why an email was injected into its system. In respect to knowing if it's a vacation response or not. But if you ask Wietse on the postfix-users@postfix.org list he would know if there are any workarounds to do what you want.
- "sieve_user_email = %u" creates a warning: "Warning: sieve: Invalid
address value for setting `sieve_user_email': Missing domain"
That warning is a glitch, ignore it. I mentioned it on the list before but has not been fixed in any of the updates.
What I am currently trying to figure out is, is there a way to tell postfix in case it is a vacation reply with no envelope to but a valid from header use that from header as a rule for choosing the right relay host.
I don't think postfix knows how or why an email was injected into its system. In respect to knowing if it's a vacation response or not. But if you ask Wietse on the postfix-users@postfix.org list he would know if there are any workarounds to do what you want.
Asked on the postfix-users list but there is no simple way to choose a relay host based on multiple headers but I found one workaround and thanks to Wietse another one "up my sleeves".
Most of the aliases use the same relay host - instead configuring it in sender_dependent_relayhost_maps I configured it as relayhost in postfix' main.cf. Now even with vaction replies with MAIL FROM being blank they get relayed correctly.
The other workoround "up my sleeves" in case I need the vacation module work for other aliases as well (which need another relay host) is to use a milter (which I already have in place) to check for a header the vacation plugin sets and an empty MAIL FROM address and add in that case another single header to let postfix filter for that (by header_checks FILTER) and choose the right relay host based on the information set in the new header - but currently I don't need that.
Thx everybody so far!
-- Cheers spi
participants (2)
-
dovecot@ptld.com
-
spi