I have been using this patch in my own copy of mairix for many years now, 
and rather than keeping it private I thought it worth sharing.

In general, it seems bad to trust the "Date:" header in incoming mails as 
this is set by the sender and is not always correct (eg. spam, incorrect 
clock)

But when Exim delivers to my mailbox, it adds a Delivery-Date. So if this 
exists, I use it instead. So inbound mail uses this, while my outbound 
mail only has a "Date:" header but this is trusted as it was set by me.

This makes searching for mails in, eg. last 3 months, work as expected 
Results are no longer polluted by those with a Date in the future, for 
example.

-- 
Mark


---
 rfc822.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rfc822.c b/rfc822.c
index 606b9cf..668acaf 100644
--- a/rfc822.c
+++ b/rfc822.c
@@ -1016,7 +1016,8 @@ struct rfc822 *data_to_rfc822(struct msg_src *src,
       cte_nvp = make_nvp(src, x->text + sizeof("content-transfer-encoding:") - 
1);
     else if (!cd_nvp && match_string("content-disposition", x->text))
       cd_nvp = make_nvp(src, x->text + sizeof("content-disposition:") - 1);
-    else if (!result->hdrs.date && match_string("date", x->text)) {
+    else if (match_string("delivery-date", x->text)
+             || !result->hdrs.date && match_string("date", x->text)) {
       char *date_string = copy_header_value(x->text);
       result->hdrs.date = parse_rfc822_date(date_string);
       free(date_string);
-- 
1.7.12.2


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Mairix-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mairix-users

Reply via email to