Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need to add custom header parameter/value to postfix logging.

1,328 views
Skip to first unread message

Guidarini, Robert

unread,
Aug 12, 2009, 9:10:00 AM8/12/09
to
--_000_9E21DB8A5EE791489819E235DB949C0E61846FFF5EUSMAILusnptvg_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


I was hoping someone would have experience in what I need to do. Our server=
s send emails to our postfix servers and include a custom header that the v=
alue is referenced in one of our databases. This concerns outgoing email on=
ly.

Example of custom header inserted into the emails:
X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg

I need to get the postfix servers to add that custom header info into the p=
ostfix log when an email is sent.

What I would like to see in the logs is something like (dream scenario):

Aug 11 16:35:37 MTA9 postfix/cleanup[1123]: E472A137E2: message-id=3D<20090=
811213537....@MTA9.somedomain.net>
Aug 11 16:35:37 MTA9 postfix/qmgr[3885]: E472A137E2: from=3D<noreply@somedo=
main.net>, size=3D3034, nrcpt=3D1 (queue active), X-Info-MessageID: l6oL1rH=
PRUyklkQzdkW3kg

Is this functionality possible and if so, how?

Robert


--_000_9E21DB8A5EE791489819E235DB949C0E61846FFF5EUSMAILusnptvg_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" xmlns:p=3D"urn:schemas-m=
icrosoft-com:office:powerpoint" xmlns:a=3D"urn:schemas-microsoft-com:office=
:access" xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s=3D"=
uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs=3D"urn:schemas-microsof=
t-com:rowset" xmlns:z=3D"#RowsetSchema" xmlns:b=3D"urn:schemas-microsoft-co=
m:office:publisher" xmlns:ss=3D"urn:schemas-microsoft-com:office:spreadshee=
t" xmlns:c=3D"urn:schemas-microsoft-com:office:component:spreadsheet" xmlns=
:odc=3D"urn:schemas-microsoft-com:office:odc" xmlns:oa=3D"urn:schemas-micro=
soft-com:office:activation" xmlns:html=3D"http://www.w3.org/TR/REC-html40" =
xmlns:q=3D"http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc=3D"http://m=
icrosoft.com/officenet/conferencing" xmlns:D=3D"DAV:" xmlns:Repl=3D"http://=
schemas.microsoft.com/repl/" xmlns:mt=3D"http://schemas.microsoft.com/share=
point/soap/meetings/" xmlns:x2=3D"http://schemas.microsoft.com/office/excel=
/2003/xml" xmlns:ppda=3D"http://www.passport.com/NameSpace.xsd" xmlns:ois=
=3D"http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir=3D"http://=
schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds=3D"http://www.w3=
.org/2000/09/xmldsig#" xmlns:dsp=3D"http://schemas.microsoft.com/sharepoint=
/dsp" xmlns:udc=3D"http://schemas.microsoft.com/data/udc" xmlns:xsd=3D"http=
://www.w3.org/2001/XMLSchema" xmlns:sub=3D"http://schemas.microsoft.com/sha=
repoint/soap/2002/1/alerts/" xmlns:ec=3D"http://www.w3.org/2001/04/xmlenc#"=
xmlns:sp=3D"http://schemas.microsoft.com/sharepoint/" xmlns:sps=3D"http://=
schemas.microsoft.com/sharepoint/soap/" xmlns:xsi=3D"http://www.w3.org/2001=
/XMLSchema-instance" xmlns:udcs=3D"http://schemas.microsoft.com/data/udc/so=
ap" xmlns:udcxf=3D"http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udc=
p2p=3D"http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf=3D"http:/=
/schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss=3D"http://sche=
mas.microsoft.com/office/2006/digsig-setup" xmlns:dssi=3D"http://schemas.mi=
crosoft.com/office/2006/digsig" xmlns:mdssi=3D"http://schemas.openxmlformat=
s.org/package/2006/digital-signature" xmlns:mver=3D"http://schemas.openxmlf=
ormats.org/markup-compatibility/2006" xmlns:m=3D"http://schemas.microsoft.c=
om/office/2004/12/omml" xmlns:mrels=3D"http://schemas.openxmlformats.org/pa=
ckage/2006/relationships" xmlns:spwp=3D"http://microsoft.com/sharepoint/web=
partpages" xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/services/20=
06/types" xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/services/200=
6/messages" xmlns:pptsl=3D"http://schemas.microsoft.com/sharepoint/soap/Sli=
deLibrary/" xmlns:spsl=3D"http://microsoft.com/webservices/SharePointPortal=
Server/PublishedLinksService" xmlns:Z=3D"urn:schemas-microsoft-com:" xmlns:=
st=3D"&#1;" xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>I was hoping someone would have experience in what I n=
eed to
do. Our servers send emails to our postfix servers and include a custom hea=
der
that the value is referenced in one of our databases. This concerns outgoin=
g
email only. &nbsp;<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Example of custom header inserted into the emails:<o:p=
></o:p></p>

<p class=3DMsoNormal>X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg<o:p></o:p></p=
>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>I need to get the postfix servers to add that custom h=
eader
info into the postfix log when an email is sent. <o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>What I would like to see in the logs is something like
(dream scenario):<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Aug 11 16:35:37 MTA9 postfix/cleanup[1123]: E472A137E2=
:
message-id=3D&lt;200908112135...@MTA9.somedomain.net&gt;<o:p></o:=
p></p>

<p class=3DMsoNormal>Aug 11 16:35:37 MTA9 postfix/qmgr[3885]: E472A137E2:
from=3D&lt;nor...@somedomain.net&gt;, size=3D3034, nrcpt=3D1 (queue active=
),
X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg<o:p></o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal>Is this functionality possible and if so, how? <o:p></=
o:p></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:#7F7F7F'>Robert </span><span style=3D'color:#7F7F7F'><o:p></o:p></spa=
n></p>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>

--_000_9E21DB8A5EE791489819E235DB949C0E61846FFF5EUSMAILusnptvg_--

Justin Piszcz

unread,
Aug 12, 2009, 9:20:39 AM8/12/09
to
Hi,

You want: PREPEND

http://www.postfix.org/header_checks.5.html


PREPEND text...
Prepend one line with the specified text, and
inspect the next input line.

Notes:

o The prepended text is output on a separate
line, immediately before the input that
triggered the PREPEND action.

o The prepended text is not considered part of
the input stream: it is not subject to
header/body checks or address rewriting, and
it does not affect the way that Postfix adds
missing message headers.

o When prepending text before a message header
line, the prepended text must begin with a
valid message header label.

o This action cannot be used to prepend multi-
line text.

This feature is available in Postfix 2.1 and later.


On Wed, 12 Aug 2009, Guidarini, Robert wrote:

>
> I was hoping someone would have experience in what I need to do. Our servers send emails to our postfix servers and include a custom header that the value is referenced in one of our databases. This concerns outgoing email only.


>
> Example of custom header inserted into the emails:
> X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg
>

> I need to get the postfix servers to add that custom header info into the postfix log when an email is sent.


>
> What I would like to see in the logs is something like (dream scenario):
>

> Aug 11 16:35:37 MTA9 postfix/cleanup[1123]: E472A137E2: message-id=<200908112135...@MTA9.somedomain.net>
> Aug 11 16:35:37 MTA9 postfix/qmgr[3885]: E472A137E2: from=<nor...@somedomain.net>, size=3034, nrcpt=1 (queue active), X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg

Thomas Gelf

unread,
Aug 12, 2009, 10:40:30 AM8/12/09
to
Thomas Gelf schrieb:
> If I didn't missunderstand him he already has those X-Info-MessageID
> headers in his mail headers, what he wants is Postfix to do is writing
> them to syslog.

That's what happens if you're at phone while writing :-/
It should read: "...already has those X-Info-MessageID headers in his
mail, what he wants Postfix to do is..."

Sorry.

> While this would probably be pretty easy with Amavis, I have no idea if
> and how he could do so using Postfix only.
>
> Best regards,
> Thomas Gelf

Wietse Venema

unread,
Aug 12, 2009, 10:43:15 AM8/12/09
to
Justin Piszcz:

> Hi,
>
> You want: PREPEND
>
> http://www.postfix.org/header_checks.5.html

Please note that you don't have to use regexp tables for this.
It should be possible to do header PREPEND actions from MySQL etc.
too, as long as you can formulate the right query.

Wietse

Thomas Gelf

unread,
Aug 12, 2009, 11:01:08 AM8/12/09
to
Wietse Venema wrote:
> Justin Piszcz:
>> You want: PREPEND

>
> Please note that you don't have to use regexp tables for this.
> It should be possible to do header PREPEND actions from MySQL etc.
> too, as long as you can formulate the right query.

>>> What I would like to see in the logs is something like (dream scenario):


>>> Aug 11 16:35:37 MTA9 postfix/qmgr[3885]: E472A137E2: from=<nor...@somedomain.net>, size=3034, nrcpt=1 (queue active), X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg

If I didn't missunderstand him he already has those X-Info-MessageID


headers in his mail headers, what he wants is Postfix to do is writing
them to syslog.

While this would probably be pretty easy with Amavis, I have no idea if

Noel Jones

unread,
Aug 12, 2009, 11:44:04 AM8/12/09
to
Thomas Gelf wrote:
> Thomas Gelf schrieb:

>> If I didn't missunderstand him he already has those X-Info-MessageID
>> headers in his mail headers, what he wants is Postfix to do is writing
>> them to syslog.
>
> That's what happens if you're at phone while writing :-/
> It should read: "...already has those X-Info-MessageID headers in his
> mail, what he wants Postfix to do is..."
>

To log an existing header, use the header_checks WARN action.
http://www.postfix.org/header_checks.5.html

The log entry would look something like:
Aug 12 10:29:59 mgate2 postfix/cleanup[29258]: 7C773797ADF:
warning: header X-Info-Messageid: l6oL1rHPRUyklkQzdkW3kg from
client.example.com[192.168.1.123]; from=<us...@example.com>
to=<reci...@example.org> proto=ESMTP helo=<[192.168.1.123]>


-- Noel Jones

Thomas Gelf

unread,
Aug 12, 2009, 11:54:48 AM8/12/09
to
Noel Jones wrote:
> To log an existing header, use the header_checks WARN action.
> http://www.postfix.org/header_checks.5.html

Thank you!

> The log entry would look something like:
> Aug 12 10:29:59 mgate2 postfix/cleanup[29258]: 7C773797ADF: warning:
> header X-Info-Messageid: l6oL1rHPRUyklkQzdkW3kg from
> client.example.com[192.168.1.123]; from=<us...@example.com>
> to=<reci...@example.org> proto=ESMTP helo=<[192.168.1.123]>

Does it automagically log the whole matching header? Or do I need to
add some backreference to "WARN optional text..."?

Regards,
Thomas

Guidarini, Robert

unread,
Aug 12, 2009, 12:10:02 PM8/12/09
to
Our application already inserts the custom header into the email. If we can=
get postfix to log the custom private ID, then the goal is to schedule ano=
ther application once a day to grab the archived mail log and parse the inf=
ormation out so we can match up our private msg ID with postfix's msg ID.=20

Thomas, you are correct: If I didn't misunderstand him he already has those=
X-Info-MessageID headers in his mail headers, what he wants is Postfix to =


do is writing them to syslog.

I'll try the WARN action and see if I can get it to work. Thanks for everyo=
ne's input.=20

Robert=20

-----Original Message-----
From: owner-pos...@postfix.org [mailto:owner-postfix-users@postfix.o=
rg] On Behalf Of Thomas Gelf
Sent: Wednesday, August 12, 2009 10:54 AM
To: postfi...@postfix.org
Subject: Re: need to add custom header parameter/value to postfix logging.

Noel Jones wrote:
> To log an existing header, use the header_checks WARN action.
> http://www.postfix.org/header_checks.5.html

Thank you!

> The log entry would look something like:
> Aug 12 10:29:59 mgate2 postfix/cleanup[29258]: 7C773797ADF: warning:
> header X-Info-Messageid: l6oL1rHPRUyklkQzdkW3kg from

> client.example.com[192.168.1.123]; from=3D<us...@example.com>
> to=3D<reci...@example.org> proto=3DESMTP helo=3D<[192.168.1.123]>

Noel Jones

unread,
Aug 12, 2009, 12:14:35 PM8/12/09
to
Thomas Gelf wrote:
> Noel Jones wrote:
>> To log an existing header, use the header_checks WARN action.
>> http://www.postfix.org/header_checks.5.html
>
> Thank you!
>
>> The log entry would look something like:
>> Aug 12 10:29:59 mgate2 postfix/cleanup[29258]: 7C773797ADF: warning:
>> header X-Info-Messageid: l6oL1rHPRUyklkQzdkW3kg from
>> client.example.com[192.168.1.123]; from=<us...@example.com>
>> to=<reci...@example.org> proto=ESMTP helo=<[192.168.1.123]>

>
> Does it automagically log the whole matching header? Or do I need to
> add some backreference to "WARN optional text..."?
>
> Regards,
> Thomas
>

The entire header (up to a sanity limit) is logged; no further
action is necessary.

-- Noel Jones

Thomas Gelf

unread,
Aug 12, 2009, 12:25:26 PM8/12/09
to
Noel Jones wrote:
> The entire header (up to a sanity limit) is logged; no further action is
> necessary.

Great, thanks again!

Bastian Blank

unread,
Aug 12, 2009, 12:32:23 PM8/12/09
to
On Wed, Aug 12, 2009 at 08:09:32AM -0500, Guidarini, Robert wrote:
> Example of custom header inserted into the emails:
> X-Info-MessageID: l6oL1rHPRUyklkQzdkW3kg

Why don't you add this to the message-id, which is mandatory and
already logged?

Bastian

--
He's dead, Jim.
-- McCoy, "The Devil in the Dark", stardate 3196.1

0 new messages