I am currently trying to distinguish between internal Users and External
users. For that I want to add [EXTERNAL] to the beginning of the Subject of
incoming Mails. (ie. I want to add this only for messages coming from a
domain which isn't owned by us). This part is actually working fine. The
Problem I am now facing, is to remove the [EXTERNAL] for outgoing mails.
This is important for replies, since these contain "Re: [EXTERNAL]
<original subject>". Not only is this not great when sending replies to
other entities outside of our organisation, it also gets really funny in
long chains... "[EXTERNAL] Re: [EXTERNAL] Re: [EXTERNAL] Re: [EXTERNAL]
<original subject>".
Problem is, that I have no clue how to remove the [EXTERNAL]. I found no
solution which works in exim itself, so I tried to push the Mail to Perl in
acl_check_data and let Perl do the heavy lifting. I gave Perl
$header_subject, stripped the [EXTERNAL] with Perls regex string
manipulation, applied the RFC 2047 encoding to the string (in case that
there are non ASCII characters in the subject), returned the result to Exim
and Exim embedded that with "add_header = Subject: $
{perl{subject_extern}}". This worked great in my test environment but broke
in Production. Apparently Exim sometimes failed to decode the message and
just gave the RFC 2047 string to Perl, which then got encoded with RFC 2047
again. This double encoded header resulted in a RFC 2047 string in the
subject line in HCL Notes. I have yet to figure out why Exim sometime
decides to not decode messages with $header_subject.
My current iteration gives the subject with $rheader_subject to Perl, and
after that I use Encode::MIME::Header in Perl to decode the header, apply
my String manipulation, reencode the Message and give the result back to
Exim. Again, works great in my testing environment but breaks in
Production. For some reason sometimes the BODY of the message gets encoded
with RFC 2047? Yeah no clue whats up with that. Oh and sometimes the header
gets cut off at around 15 characters.
So yeah.. before I bash my head further against a wall, is there a Proper
way in Exim to do that?