[Dovecot] How to rewrite header from X-Original-To to Delivered-To
HiAll,
How to rewrite mail headers from X-Original-To to Delivered-To using sieve script.
I am using Dovecot-2.2 and Pigeonhole 0.4.
Thanks, Kiran Reddy
Op 5/24/2013 10:39 AM, Kiran Reddy schreef:
HiAll,
How to rewrite mail headers from X-Original-To to Delivered-To using sieve script.
I am using Dovecot-2.2 and Pigeonhole 0.4.
Ehmmm.. why do you need to do that? :)
Anyway, something like this:
require "editheader"; require "variables";
# Take value from first header occurrence if header :matches "X-Original-To" "*" { # delete existing headers to prevent creating duplicate (optional) deleteheader "Delivered-To";
# add the new header
addheader "Delivered-To" "${1}";
# delete old header (optional)
deleteheader "X-Original-To";
}
Regards,
Stephan.
Hi,
If mail headers contains 2 lines Delivered-To and 1 X-Original-To. I want to keep first line of Delivered-To and X-Original-To and delete 2nd line of Delivered-To and rewrite X-Original-To to Delivered-To.
Please find the mail headers as below.
X-Original-To: 98862xxx65@example.in ====> Rewrite this to Delivered-TO Delivered-To: mobilemail@example.in ====> KEEP This Header Delivered-To: example.com-mobilenumbers@example.com =======> Delete This Header
Return-Path: syed.s@example.com X-Original-To: 98862xxx65@example.in ====> Rewrite this to Delivered-TO Delivered-To: mobilemail@example.in ====> KEEP This Header Received: from localhost (mail.example.in [127.0.0.1]) by mail.example.in (Postfix) with ESMTP id 2D34CC2C8103 for 98862xxx65@example.in; Tue, 14 May 2013 17:04:59 +0530 (IST) X-Virus-Scanned: amavisd-new at mail.example.in Received: from mail.example.in ([127.0.0.1]) by localhost (mail.example.in [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lMJ9xX4+xvVE for 98862xxx65@example.in; Tue, 14 May 2013 17:04:58 +0530 (IST) Received: from s461.sureserver.com (unknown [64.14.73.27]) by mail.example.in (Postfix) with ESMTPS id 5A7C7C2C8104 for 9886232265@example.in; Tue, 14 May 2013 17:04:55 +0530 (IST) Received: (qmail 3678 invoked by uid 1003); 14 May 2013 11:34:53 -0000 Delivered-To: example.com-mobilenumbers@example.com =======> Delete This Header Received: (qmail 3611 invoked by uid 1003); 14 May 2013 11:34:52 -0000 Received: from unknown (HELO ?172.16.6.226?) (syed.s@110.234.117.194) by s461.sureserver.com with ESMTPA; 14 May 2013 11:34:52 -0000 Message-ID: 51922159.9030505@example.com Date: Tue, 14 May 2013 17:04:49 +0530 From: Syed Sharfuddin syed.s@example.com User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: mobilenumbers@example.com Subject: Fwd: Fwd: TEST EMAIL
Thanks, Kiran Reddy
On 5/24/2013 2:27 PM, Stephan Bosch wrote:
Op 5/24/2013 10:39 AM, Kiran Reddy schreef:
HiAll,
How to rewrite mail headers from X-Original-To to Delivered-To using sieve script.
I am using Dovecot-2.2 and Pigeonhole 0.4.
Ehmmm.. why do you need to do that? :)
Anyway, something like this:
require "editheader"; require "variables";
# Take value from first header occurrence if header :matches "X-Original-To" "*" { # delete existing headers to prevent creating duplicate (optional) deleteheader "Delivered-To";
# add the new header addheader "Delivered-To" "${1}"; # delete old header (optional) deleteheader "X-Original-To";
}
Regards,
Stephan.
Op 5/24/2013 1:45 PM, Kiran Reddy schreef:
Hi,
If mail headers contains 2 lines Delivered-To and 1 X-Original-To. I want to keep first line of Delivered-To and X-Original-To and delete 2nd line of Delivered-To and rewrite X-Original-To to Delivered-To.
Please find the mail headers as below.
X-Original-To: 98862xxx65@example.in ====> Rewrite this to Delivered-TO Delivered-To: mobilemail@example.in ====> KEEP This Header Delivered-To: example.com-mobilenumbers@example.com =======> Delete This Header
If you can rely on the exact order of these headers, this should work:
require "editheader"; require "variables";
if header :matches "X-Original-To" "*" { deleteheader :index 2 "Delivered-To"; addheader "Delivered-To" "${1}"; deleteheader "X-Original-To"; }
Regards,
Stephan.
Thanks for quick reply.
a {color: #F77A1E;} On 5/24/2013 5:39 PM, Stephan Bosch wrote:
Op 5/24/2013 1:45 PM, Kiran Reddy schreef:
Hi,
If mail headers contains 2 lines Delivered-To and 1 X-Original-To. I want to keep first line of Delivered-To and X-Original-To and delete 2nd line of Delivered-To and rewrite X-Original-To to Delivered-To.
Please find the mail headers as below.
X-Original-To: 98862xxx65@example.in ====> Rewrite this to Delivered-TO Delivered-To: mobilemail@example.in ====> KEEP This Header Delivered-To: example.com-mobilenumbers@example.com =======> Delete This Header
If you can rely on the exact order of these headers, this should work:
require "editheader"; require "variables";
if header :matches "X-Original-To" "*" { deleteheader :index 2 "Delivered-To"; addheader "Delivered-To" "${1}"; deleteheader "X-Original-To"; }
Regards,
Stephan.
participants (2)
-
Kiran Reddy
-
Stephan Bosch