0

I very successfully dealt with single line headers in pcre:/etc/postfix/header_check. But when it comes to multi-lines, I'm a bit frustrated. Here is a part of header:

X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Content-Type: multipart/alternative;
    boundary="_000_8FA6C259529CB0418FBDF96A6B22A486209F15MAILmynetworkloca_"
MIME-Version: 1.0

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

test

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

And what I need, just to get rid of strings like

--_000_8FA6C259529CB0418FBDF96A6B22A486209F15MAILmynetworkloca_

Or at least replace last part MAILmynetworkloca_ to something like maildomaincom_ I've tried to put to my /etc/postfix/header_check

/MAILmynetworkloca_/ REPLACE maildomaincom_

but it didn't work

2
  • Boundary parts isn't visible directly to user. It's only used by mail client to mark attachment boundary. Why do you want to replace it?
    – masegaloeh
    Nov 26, 2014 at 9:33
  • @masegaloeh All my users use the same exchange server, but different domains. So all their emails should not contain anything in common even in mail headers
    – Shirker
    Nov 28, 2014 at 0:10

2 Answers 2

2

FYI: The line --__INSERTSOMERANDOCHARHERE000MAILmynetwok isn't part of email headers. And maybe you don't wanna to alter/remove it.

Anyway, here to do it.

You should use both header_checks and body_checks to replace those line.

Content of main.cf

body_checks = pcre:/etc/postfix/mimereplace
header_checks = pcre:/etc/postfix/mimereplace

Content of /etc/postfix/mimereplace

/^(.*)MAILmynetworkloca_(.*)/ REPLACE ${1}maildomaincom_${2}
4
  • bad REPLACE header text "boundary="_000_E6E9F66E17B7214FBDC69E9F8F4DDE8D33EF94maildomaincom_" in mime_header_checks map -- need "headername: headervalue". But I dont know the header name?
    – Shirker
    Nov 27, 2014 at 23:53
  • yes, this worked for me! thank you. All were replaced. But the weird thing now - gmail doesnt want to show message body as html anymore? Why is that?
    – Shirker
    Nov 28, 2014 at 0:55
  • i figured out the HTML problems. Header replace somehow is removing last '"' from boundary. so in header_checks it should be like ....REPLACE ${1}maildomaincom_" with " at the end
    – Shirker
    Nov 28, 2014 at 1:04
  • i've made some changes for your answer. this is fully working version. Thank you for your help
    – Shirker
    Nov 28, 2014 at 1:20
0

I think you'll want to use something like /MAILmynetworkloca_$/m REPLACE maildomaincom_ .

The dollar sign means at the end of the string, the m should put it in multiline mode (according to the PCRE pages)

Why you'd want to replace that header I don't know, but it's your mail server :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .