DevHeads.net

need help with pcre for postfix

hi,

i don't understand how the filter are processed ?

can someone help me write a filter who would accept mail for
"postmaster@domain" and reject all other mails ?

Comments

RE: need help with pcre for postfix

By Sharma, Ashish at 11/06/2009 - 06:17

Pascal,

You can create a mail filter for Postfix using Milter API.

For c implementation you can use lib-milter API and for Java implementation you can use 'Jilter' API.

It's possible to write code depending on your requirement as mentioned by you:

I have a sample Jilter implementation in java for understanding Jilter implementation, reply if you need it.

Check these links for more info:
<a href="http://en.wikipedia.org/wiki/Milter" title="http://en.wikipedia.org/wiki/Milter">http://en.wikipedia.org/wiki/Milter</a>
<a href="https://www.sendmail.org/doc/sendmail-current/libmilter/docs/" title="https://www.sendmail.org/doc/sendmail-current/libmilter/docs/">https://www.sendmail.org/doc/sendmail-current/libmilter/docs/</a>
<a href="http://www.sendmail.org/doc/sendmail-current/libmilter/README" title="http://www.sendmail.org/doc/sendmail-current/libmilter/README">http://www.sendmail.org/doc/sendmail-current/libmilter/README</a>
<a href="http://sendmail-jilter.sourceforge.net/" title="http://sendmail-jilter.sourceforge.net/">http://sendmail-jilter.sourceforge.net/</a>

Ashish

hi,

i don't understand how the filter are processed ?

can someone help me write a filter who would accept mail for
"postmaster@domain" and reject all other mails ?

Re: need help with pcre for postfix

By Victor Duchovni at 11/06/2009 - 15:56

Massive overkill for a simple recipient address access policy.

Re: need help with pcre for postfix

By pascal valois at 11/18/2009 - 04:17

Viktor,

Yes, Milter seems way to much for what i wanna do.

i installed postfix-pcre on ubuntu 8.04.

and add this line in my main.cf postfix configuration :

header_checks = pcre:/etc/postfix/header_checks

then here is the content of my /etc/postfix/header_checks :

!/postmaster@devinci\.fr/ REJECT go away

but when this is enables, all mail are rejected.

can anyone help me with this ?

Le vendredi 06 novembre 2009 à 14:56 -0500, Victor Duchovni a écrit :

Re: need help with pcre for postfix

By Victor Duchovni at 11/18/2009 - 12:53

Why are using header checks to filter the envelope recipient address?
(Hint: DO NOT).

<a href="http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions" title="http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions">http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions</a>
<a href="http://www.postfix.org/postconf.5.html#check_recipient_access" title="http://www.postfix.org/postconf.5.html#check_recipient_access">http://www.postfix.org/postconf.5.html#check_recipient_access</a>
<a href="http://www.postfix.org/access.5.html" title="http://www.postfix.org/access.5.html">http://www.postfix.org/access.5.html</a>

Find a decent tutorial on Postfix restriction processing.

Don't reject all messages that contain header lines that don't mention
the postmaster address.

Re: need help with pcre for postfix

By pascal valois at 11/18/2009 - 04:32

hum, i think i found what was wrong.

when checking with pcre, all lines in the header are processed. and then
the "from: adress" get a REJECT go away reponse from the filter.

i though that all the subject was processed as once ?

right or wrong ?

Le mercredi 18 novembre 2009 à 09:17 +0100, pascal valois a écrit :

Re: need help with pcre for postfix

By Victor Duchovni at 11/04/2009 - 13:48

<a href="http://www.postfix.org/access.5.html" title="http://www.postfix.org/access.5.html">http://www.postfix.org/access.5.html</a>
<a href="http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions" title="http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions">http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions</a>
<a href="http://www.postfix.org/postconf.5.html#check_recipient_access" title="http://www.postfix.org/postconf.5.html#check_recipient_access">http://www.postfix.org/postconf.5.html#check_recipient_access</a>

A lot depends on the type of domain, for "virtual alias" domains for
example, just don't create any virtual alias table entries for any
other users in the domain.

<a href="http://www.postfix.org/ADDRESS_CLASS_README.html" title="http://www.postfix.org/ADDRESS_CLASS_README.html">http://www.postfix.org/ADDRESS_CLASS_README.html</a>
<a href="http://www.postfix.org/VIRTUAL_README.html" title="http://www.postfix.org/VIRTUAL_README.html">http://www.postfix.org/VIRTUAL_README.html</a>
<a href="http://www.postfix.org/virtual.5.html" title="http://www.postfix.org/virtual.5.html">http://www.postfix.org/virtual.5.html</a>
<a href="http://www.postfix.org/postconf.5.html#virtual_alias_maps" title="http://www.postfix.org/postconf.5.html#virtual_alias_maps">http://www.postfix.org/postconf.5.html#virtual_alias_maps</a>
<a href="http://www.postfix.org/postconf.5.html#virtual_alias_domains" title="http://www.postfix.org/postconf.5.html#virtual_alias_domains">http://www.postfix.org/postconf.5.html#virtual_alias_domains</a>

None of this has anything to do with "pcre" per-se. Why do you believe
you need PCRE to implement a policy that only accepts mail for certain
recipients?