modifying outbound email headers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

modifying outbound email headers

Stefan Claas
Hi,

my postfix mail server works perfectly so far.

However, I am now facing the following problem and have tried as best as I can
to find a solution to this.

I run an anonymous remailer, which also allows sending emails to mail2news
gateways for Usenet postings. So far so good.

I would like to achieve the following:

postfix should modify outgoing email headers that *only* go to mail2news
gateways, using the email gateway addresses for parsing, so that the right part
of the message ID, after the @ charachter, will be modified with a defined
string.

postfix must *not* change message IDs for regular emails.

I would be very grateful for your help!

Greetings
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas
           
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

mahe-2
Hi Stefan,

> I would like to achieve the following:
>
> postfix should modify outgoing email headers that *only* go to
> mail2news
> gateways, using the email gateway addresses for parsing, so that the
> right part
> of the message ID, after the @ charachter, will be modified with a
> defined
> string.

Not sure if Postfix can do the Job. However, Procmail will do the Job, I
think.

Franck MAHE
=======================
@: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Stefan Claas
Franck MAHE wrote:

> Hi Stefan,
>
> > I would like to achieve the following:
> >
> > postfix should modify outgoing email headers that *only* go to
> > mail2news
> > gateways, using the email gateway addresses for parsing, so that the
> > right part
> > of the message ID, after the @ charachter, will be modified with a
> > defined
> > string.
>
> Not sure if Postfix can do the Job. However, Procmail will do the Job, I
> think.

Hi Frank,

I must admit that I am not an expert, but what I have seen so far, it
looks to me that procmail is used for inbound mail. Hope that I am
wrong with that.

Because my request is pretty unusal, I assume, I desperately hope that
someone can show me a solution!

Regards
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas
           
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Matus UHLAR - fantomas
In reply to this post by Stefan Claas
On 06.04.20 11:01, Stefan Claas wrote:
>my postfix mail server works perfectly so far.
>
>However, I am now facing the following problem and have tried as best as I can
>to find a solution to this.
>
>I run an anonymous remailer, which also allows sending emails to mail2news
>gateways for Usenet postings. So far so good.
>
>I would like to achieve the following:

>postfix should modify outgoing email headers that *only* go to mail2news
>gateways, using the email gateway addresses for parsing, so that the right part
>of the message ID, after the @ charachter, will be modified with a defined
>string.

your mail2news gateway should do that.

>postfix must *not* change message IDs for regular emails.

--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
My mind is like a steel trap - rusty and illegal in 37 states.
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Gregory Heytings
In reply to this post by Stefan Claas

Stefan Claas:
>
> postfix should modify outgoing email headers that *only* go to mail2news
> gateways, using the email gateway addresses for parsing, so that the
> right part of the message ID, after the @ charachter, will be modified
> with a defined string.
>

Do you mean "should modify outgoing email headers that only go to
mail2news gateways" or "should only modify outgoing email headers that go
to mail2news gateways"?  What should happen if an email is sent both to
one or more regular email addresses and to a mail2news gateway?

What you want to do seems to be a job for a milter:  Depending on the
"RCPT TO" line (or on the "To:" header), modify the "Message-ID:" header.
Such a conditional header modification cannot be done from inside Postfix.
The only available mechanism to modify email headers is
smtp_header_checks, but it works line by line: "Each message header or
message body line is compared against a list of patterns.  When a match is
found the corresponding action is executed, and the matching process is
repeated for the next message header or message body line."

Gregory
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

mahe-2
In reply to this post by Stefan Claas
>> > I would like to achieve the following:
>> >
>> > postfix should modify outgoing email headers that *only* go to
>> > mail2news
>> > gateways, using the email gateway addresses for parsing, so that the
>> > right part
>> > of the message ID, after the @ charachter, will be modified with a
>> > defined
>> > string.
>>
>> Not sure if Postfix can do the Job. However, Procmail will do the Job,
>> I
>> think.

> I must admit that I am not an expert, but what I have seen so far, it
> looks to me that procmail is used for inbound mail. Hope that I am
> wrong with that.

Procmail can be used for Outbound mail as well.

Franck MAHE
=======================
@: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Stefan Claas
In reply to this post by Matus UHLAR - fantomas
Matus UHLAR - fantomas wrote:

> On 06.04.20 11:01, Stefan Claas wrote:
> >my postfix mail server works perfectly so far.
> >
> >However, I am now facing the following problem and have tried as best as I
> >can to find a solution to this.
> >
> >I run an anonymous remailer, which also allows sending emails to mail2news
> >gateways for Usenet postings. So far so good.
> >
> >I would like to achieve the following:
>
> >postfix should modify outgoing email headers that *only* go to mail2news
> >gateways, using the email gateway addresses for parsing, so that the right
> >part of the message ID, after the @ charachter, will be modified with a
> >defined string.
>
> your mail2news gateway should do that.

I thought that as well, but the problem would be when users send the same
message to multiple mail2news gateways, which is often the case, the News
articles would then arrive with different message-IDs.

Regards
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas
           
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Stefan Claas
In reply to this post by Gregory Heytings
Gregory Heytings wrote:

>
> Stefan Claas:
> >
> > postfix should modify outgoing email headers that *only* go to mail2news
> > gateways, using the email gateway addresses for parsing, so that the
> > right part of the message ID, after the @ charachter, will be modified
> > with a defined string.
> >
>
> Do you mean "should modify outgoing email headers that only go to
> mail2news gateways" or "should only modify outgoing email headers that go
> to mail2news gateways"?  What should happen if an email is sent both to
> one or more regular email addresses and to a mail2news gateway?

I am no native English speaker, but would say the latter.

About your second question, I have not thought about that, I must admit.

To keeps things as simple as possible I would like to concentrate first
only for the case that the messages go only to mail2news gateways, which
I could explain then to users, of my service.

> What you want to do seems to be a job for a milter:  Depending on the
> "RCPT TO" line (or on the "To:" header), modify the "Message-ID:" header.
> Such a conditional header modification cannot be done from inside Postfix.
> The only available mechanism to modify email headers is
> smtp_header_checks, but it works line by line: "Each message header or
> message body line is compared against a list of patterns.  When a match is
> found the corresponding action is executed, and the matching process is
> repeated for the next message header or message body line."

Ah, ok. Thanks a lot for the information!

Because I am no expert with postfix, can you recommend easy to understand
milter example links, I can learn from?

Regards
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas
           
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Stefan Claas
In reply to this post by mahe-2
Franck MAHE wrote:

> >> > I would like to achieve the following:
> >> >
> >> > postfix should modify outgoing email headers that *only* go to
> >> > mail2news
> >> > gateways, using the email gateway addresses for parsing, so that the
> >> > right part
> >> > of the message ID, after the @ charachter, will be modified with a
> >> > defined
> >> > string.
> >>
> >> Not sure if Postfix can do the Job. However, Procmail will do the Job,
> >> I
> >> think.
>
> > I must admit that I am not an expert, but what I have seen so far, it
> > looks to me that procmail is used for inbound mail. Hope that I am
> > wrong with that.
>
> Procmail can be used for Outbound mail as well.

Thanks, didn't know that.

Regards
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas
           
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Wietse Venema
In reply to this post by Stefan Claas
Stefan Claas:

> Hi,
>
> my postfix mail server works perfectly so far.
>
> However, I am now facing the following problem and have tried as best as I can
> to find a solution to this.
>
> I run an anonymous remailer, which also allows sending emails to mail2news
> gateways for Usenet postings. So far so good.
>
> I would like to achieve the following:
>
> postfix should modify outgoing email headers that *only* go to mail2news
> gateways, using the email gateway addresses for parsing, so that the right part
> of the message ID, after the @ charachter, will be modified with a defined
> string.

Do it in the mail2news gateway.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Matus UHLAR - fantomas
In reply to this post by Stefan Claas
>> On 06.04.20 11:01, Stefan Claas wrote:
>> >my postfix mail server works perfectly so far.
>> >
>> >However, I am now facing the following problem and have tried as best as I
>> >can to find a solution to this.
>> >
>> >I run an anonymous remailer, which also allows sending emails to mail2news
>> >gateways for Usenet postings. So far so good.
>> >
>> >I would like to achieve the following:
>>
>> >postfix should modify outgoing email headers that *only* go to mail2news
>> >gateways, using the email gateway addresses for parsing, so that the right
>> >part of the message ID, after the @ charachter, will be modified with a
>> >defined string.

>Matus UHLAR - fantomas wrote:
>> your mail2news gateway should do that.

On 06.04.20 12:43, Stefan Claas wrote:
>I thought that as well, but the problem would be when users send the same
>message to multiple mail2news gateways, which is often the case, the News
>articles would then arrive with different message-IDs.

you can instruct your mail2news gateway to modify message-id in exactly the
same way you described. In such case the result will be the same.

However, Usenet news use Message-ID for duplicity deteaction and I see
caveats:

- if user sends the same message to multiple gateways (one on your system,
  one on other), duplicate news article will be created, one with original
  message-id, another with what you modify it to.

- if user sends te same message multiple times to mail2news gateway, the
  article will be only created once and second post will be rejected.

I recommend keeping the message-id to avoid duplicates. Multiple postings
ave to be solved different way.
--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Honk if you love peace and quiet.
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Wietse Venema
In reply to this post by Stefan Claas
Stefan Claas:

> Wietse Venema wrote:
>
> > Stefan Claas:
> > > Hi,
> > >
> > > my postfix mail server works perfectly so far.
> > >
> > > However, I am now facing the following problem and have tried as best as I
> > > can to find a solution to this.
> > >
> > > I run an anonymous remailer, which also allows sending emails to mail2news
> > > gateways for Usenet postings. So far so good.
> > >
> > > I would like to achieve the following:
> > >
> > > postfix should modify outgoing email headers that *only* go to mail2news
> > > gateways, using the email gateway addresses for parsing, so that the right
> > > part of the message ID, after the @ charachter, will be modified with a
> > > defined string.
> >
> > Do it in the mail2news gateway.
>
> Oh ... I would have expected a different answer from you.
>
> Like I previously replied in this thread, users are using often multiple
> mail2news gateways when posting messages to Usenet and this would then
> result in different message-ids for the same posting.

Who said that users can only use your Postfix system to post
to news gateways?

Anyway, if you can identify all the the mail2news gateways AND your users
must use your server set up a transport map:

/etc/postfix/main.cf
    transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport:
    [hidden email] newsgateway:
    [hidden email] newsgateway:

(or use a pcre: map if you want broader coverage).

/etc/postfix/master.cf:
    newsgateway      unix  -       -       n       -       -       smtp
        -o header_checks=pcre:/etc/postfix/news-header-checks.pcre

Then populate news-header-checks.pcre with all the patterns that
you need to modify or discard information. It will of course break
DKIM signatures so be aware of that in your DMARC policies.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Stefan Claas
Wietse Venema wrote:

> Stefan Claas:
> > Wietse Venema wrote:
> >
> > > Stefan Claas:
> > > > Hi,
> > > >
> > > > my postfix mail server works perfectly so far.
> > > >
> > > > However, I am now facing the following problem and have tried as best
> > > > as I can to find a solution to this.
> > > >
> > > > I run an anonymous remailer, which also allows sending emails to
> > > > mail2news gateways for Usenet postings. So far so good.
> > > >
> > > > I would like to achieve the following:
> > > >
> > > > postfix should modify outgoing email headers that *only* go to mail2news
> > > > gateways, using the email gateway addresses for parsing, so that the
> > > > right part of the message ID, after the @ charachter, will be modified
> > > > with a defined string.
> > >
> > > Do it in the mail2news gateway.
> >
> > Oh ... I would have expected a different answer from you.
> >
> > Like I previously replied in this thread, users are using often multiple
> > mail2news gateways when posting messages to Usenet and this would then
> > result in different message-ids for the same posting.
>
> Who said that users can only use your Postfix system to post
> to news gateways?

Nobody, sorry if it sounded like that!
 

> Anyway, if you can identify all the the mail2news gateways AND your users
> must use your server set up a transport map:
>
> /etc/postfix/main.cf
>     transport_maps = hash:/etc/postfix/transport
>
> /etc/postfix/transport:
>     [hidden email] newsgateway:
>     [hidden email] newsgateway:
>
> (or use a pcre: map if you want broader coverage).
>
> /etc/postfix/master.cf:
>     newsgateway      unix  -       -       n       -       -       smtp
> -o header_checks=pcre:/etc/postfix/news-header-checks.pcre
>
> Then populate news-header-checks.pcre with all the patterns that
> you need to modify or discard information. It will of course break
> DKIM signatures so be aware of that in your DMARC policies.
>
> Wietse

Thanks a lot for your help, much appreciated!

Best regards
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas
           
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Wietse Venema
One correction:

> > Anyway, if you can identify all the the mail2news gateways AND your users
> > must use your server set up a transport map:
> >
> > /etc/postfix/main.cf
> >     transport_maps = hash:/etc/postfix/transport
> >
> > /etc/postfix/transport:
> >     [hidden email] newsgateway:
> >     [hidden email] newsgateway:
> >
> > (or use a pcre: map if you want broader coverage).
> >
> > /etc/postfix/master.cf:
> >     newsgateway      unix  -       -       n       -       -       smtp
> > -o header_checks=pcre:/etc/postfix/news-header-checks.pcre

That should be smtp_header_checks (make changes while delivering),
not header_checks (make changes while receiving).

        Wietse

> > Then populate news-header-checks.pcre with all the patterns that
> > you need to modify or discard information. It will of course break
> > DKIM signatures so be aware of that in your DMARC policies.
> >
> > Wietse
>
> Thanks a lot for your help, much appreciated!
>
> Best regards
> Stefan
>
> --
> Signal (Desktop) +4915172173279
> https://keybase.io/stefan_claas
>            
>
Reply | Threaded
Open this post in threaded view
|

Re: modifying outbound email headers

Stefan Claas
Wietse Venema wrote:

> One correction:
> > > Anyway, if you can identify all the the mail2news gateways AND your users
> > > must use your server set up a transport map:
> > >
> > > /etc/postfix/main.cf
> > >     transport_maps = hash:/etc/postfix/transport
> > >
> > > /etc/postfix/transport:
> > >     [hidden email] newsgateway:
> > >     [hidden email] newsgateway:
> > >
> > > (or use a pcre: map if you want broader coverage).
> > >
> > > /etc/postfix/master.cf:
> > >     newsgateway      unix  -       -       n       -       -       smtp
> > > -o header_checks=pcre:/etc/postfix/news-header-checks.pcre
>
> That should be smtp_header_checks (make changes while delivering),
> not header_checks (make changes while receiving).

Thanks for the correction!

Best regards
Stefan

--
Signal (Desktop) +4915172173279
https://keybase.io/stefan_claas