[horde] Sieve filter for "phrase" part of address

Jens-U. Mozdzen jmozdzen at nde.ag
Thu Jul 2 14:16:04 UTC 2020


Hi *,

using Sieve, I'm trying to filter on the "phrase" part of a From: address.

Example: "Horde monitor <noreply at monitor.server.com>"

I'd like to have a rule inserted via Ingo (3.2.16), that reads

if header :contains "From" "Horde monitor"
{
   ...
}

but I fail to create that. Even if I select "custom header" while  
creating the rule, inserting "From" in the according field results in

if address :all :comparator "i;ascii-casemap" :contains "From" "Horde  
monitor" {
   ...
}

But according to RFC 5228, "the address primitive never acts on the  
phrase part of an email address or on comments within that address".

I've found basically the same question on the Ingo mailing list from  
2014, was this ever resolved?  
https://marc.info/?l=ingo&m=141838605317303&w=2


That special handling of "From" etc is due to Ingo_Script_Sieve::_generate():

--- cut here: Ingo_Script_Sieve::_generate() ---
721                     /* Do 'smarter' searching for fields where we  
know we have
722                      * e-mail addresses. */
723                     if (preg_match('/^(From|To|Cc|Bcc)/',  
$condition['field'])) {
724                         $vals['addresses'] = $condition['value'];
725                         $use_address_test = true;
726                     } else {
727                         $vals['strings'] = $condition['value'];
728                     }
--- cut here ---

If I replace that to just set $vals['strings'] = $condition['value'] ,  
then *any* check results in header check, so it's likely that's how  
Ingo currently works: Enter any rule as a header field rule and decide  
only during generating which test to use.

Any chance to extend this in a way that we may i.e. specify a magic  
value as a field name (i. e. "_header_From"), which then is replaced  
after above lines by just "From" (and thus remains a header check),  
and doing the inverse when reading in the current Sieve script?

Regards,
Jens



More information about the horde mailing list