Add Header only if sent via sendmail

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Add Header only if sent via sendmail

lutz.niederer
Hello,
 
I am looking for a simple way to add a header if and only if mail is sent locally via sendmail (mail/mailx) command.
We need to know who/what sent an email.  We already get the client's IP address if sent using smtp via smtpd_client_restrictions, but if it is not sent via smtp I have no clue how to add a header except using header_checks that adds this header for all mails.
Any (simple) ideas?
 
Thank you!
-lutzn
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Add Header only if sent via sendmail

Viktor Dukhovni
> On Mar 21, 2019, at 11:55 PM, [hidden email] wrote:
>
> I am looking for a simple way to add a header if and only if mail is sent locally via sendmail (mail/mailx) command.
> We need to know who/what sent an email.  We already get the client's IP address if sent using smtp via smtpd_client_restrictions, but if it is not sent via smtp I have no clue how to add a header except using header_checks that adds this header for all mails.
> Any (simple) ideas?

Separate cleanup(8) instances for pickup(8) and smtpd(8).  Or separate
content_filters.  Each cleanup(8) instance (chosen via cleanup_service_name)
can have its own setting of header_checks.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Add Header only if sent via sendmail

lutz.niederer
But how can I do this?
In master.cf I add a service eg called "mycleanup" with
mycleanup unix ... cleanup -o header_checks=file
Essentially a renamed copy of the cleanup service with -o header_checks
Then I add the parameter -o cleanup_service_name=mycleanup to existing pickup
I don't need to touch smtpd if I don't mind getting the IP address via client_restrictions, too.
Is that correct?  Did I miss something?
-lutzn
 
Gesendet: Freitag, 22. März 2019 um 06:30 Uhr
Von: "Viktor Dukhovni" <[hidden email]>
An: "Postfix users" <[hidden email]>
Betreff: Re: Add Header only if sent via sendmail
> On Mar 21, 2019, at 11:55 PM, [hidden email] wrote:
>
> I am looking for a simple way to add a header if and only if mail is sent locally via sendmail (mail/mailx) command.
> We need to know who/what sent an email. We already get the client's IP address if sent using smtp via smtpd_client_restrictions, but if it is not sent via smtp I have no clue how to add a header except using header_checks that adds this header for all mails.
> Any (simple) ideas?

Separate cleanup(8) instances for pickup(8) and smtpd(8). Or separate
content_filters. Each cleanup(8) instance (chosen via cleanup_service_name)
can have its own setting of header_checks.

--
Viktor.
 
Reply | Threaded
Open this post in threaded view
|

Re: Add Header only if sent via sendmail

Viktor Dukhovni
> On Mar 22, 2019, at 3:00 AM, [hidden email] wrote:
>
> But how can I do this?

As noted below.

> In master.cf I add a service eg called "mycleanup" with
> mycleanup unix ... cleanup -o header_checks=file

Well, not "=file" but "=pcre:file" or similar.

> Essentially a renamed copy of the cleanup service with -o header_checks
> Then I add the parameter -o cleanup_service_name=mycleanup to existing pickup
> I don't need to touch smtpd if I don't mind getting the IP address via client_restrictions, too.
> Is that correct?

Yes.

>  Did I miss something?

No.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Add Header only if sent via sendmail

lutz.niederer
It seems to work.
Thank you!
 
Gesendet: Freitag, 22. März 2019 um 16:15 Uhr
Von: "Viktor Dukhovni" <[hidden email]>
An: "Postfix users" <[hidden email]>
Betreff: Re: Add Header only if sent via sendmail
> On Mar 22, 2019, at 3:00 AM, [hidden email] wrote:
>
> But how can I do this?

As noted below.

> In master.cf I add a service eg called "mycleanup" with
> mycleanup unix ... cleanup -o header_checks=file

Well, not "=file" but "=pcre:file" or similar.

> Essentially a renamed copy of the cleanup service with -o header_checks
> Then I add the parameter -o cleanup_service_name=mycleanup to existing pickup
> I don't need to touch smtpd if I don't mind getting the IP address via client_restrictions, too.
> Is that correct?

Yes.

> Did I miss something?

No.

--
Viktor.