Content filtering using MySQL table

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

Content filtering using MySQL table

Jeff Weinberger-4
Hi:

I"m using content filtering by using the following (this is the example) syntax in master.cf:

smtp      inet  ...other stuff here, do not change...   smtpd
        -o content_filter=myfilter:myfilter
myfilter     unix  -       n       n       -       10      pipe
   flags......

All is working as expected.

According to the directive documentation, the content_filter directive I am using above can take a transport(5) table (hash:, pcre:, etc.) to use different transports for different domains

Does anyone know if I can use a MySQL lookup for this? with a syntax like:

smtp      inet  ...other stuff here, do not change...   smtpd
        -o content_filter=mysql:/etc/postfix/mysql_filter_maps.cf
with mysql_filter_maps.cf using a syntax like:


user = postfix_sql_user
password = postfix_sql_password
hosts = localhost
dbname = postfix_sql_database_name
query = SELECT filter_result FROM filter_table WHERE domain='%s' 

The reason I'd do this is to be able to add a domain or change content filtering for a domain on the fly without having to reload postfix

Also - what happens if I don't want content filtering for a domain, and I just don't have that domain in the lookup table? (i.e. the query returns a NULL result or no rows found result?

The desired outcome is that no content filtering is performed,

Any help or advice is much appreciated! Thank you!

Reply | Threaded
Open this post in threaded view
|

Re: Content filtering using MySQL table

mouss-2
Jeff Weinberger wrote:

> Hi:
>
> I"m using content filtering by using the following (this is the example)
> syntax in master.cf:
>
> smtp      inet  ...other stuff here, do not change...   smtpd
>         -o content_filter=myfilter:myfilter
> myfilter     unix  -       n       n       -       10      pipe
>    flags......
>
> All is working as expected.
>
> According to the directive documentation, the content_filter directive I
> am using above can take a transport(5) table (hash:, pcre:, etc.) to use
> different transports for different domains


no, it does not. it is the value of content_filter that has the same
syntax as the _result_ from a transport map. content_filter may not be a
map.

>
> Does anyone know if I can use a MySQL lookup for this? with a syntax like:
>
> [snip]
>


if you want per recipient filtering, use multiple instances and then use
transport_maps insted of content_filter. alternatively, do the check in
the filter.

note that using a FILTER statement in a check_recipient_access call
doesn't always work "as intended", because one content_filter is used
even if there are multiple recipients.