Sieve: adding Date: header when missing

Daniele Nicolodi daniele at
Thu Jul 17 16:21:31 UTC 2014

On 17/07/2014 16:51, Alex JOST wrote:
> Am 17.07.2014 16:13, schrieb Daniele Nicolodi:
>> Hello,
>> there is a way with a sieve rule to add a Date: header when it is
>> missing?  Adding one with the time of reception of the message or using
>> the date from the the first Received: header would be good options.
>> Unfortunately I'm receiving some useful automated messages that lack a
>> Date header and this screws up the sorting in my imap clients.  I have a
>> script to fix those acting on the Maildir storage, but I would prefer to
>> have the thing solved more radically.
>> Thanks. Cheers,
>> Daniele
> Finally, currentdate can be used in conjunction with the editheader 
> extension to insert a header-field containing date/time information:
> 	require ["variables", "date", "editheader"];
> 	if currentdate :matches "std11" "*"
> 	{addheader "Processing-date" "${0}";}

Thanks Alex,

I expanded this a bit to use the date from the Received header:

   if not exists "Date" {
     if date :matches "received" "std11" "*" {
       addheader "Date" "${0}";

However I believe the issue is better fixed in the MTA and I instructed
my Postfix to do it.


More information about the dovecot mailing list