advanced mysql lookup

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

advanced mysql lookup

Scappatura Rocco
Hello,

I would like to add further condition for delivery of email messages.

In my main.cf I have this setting:

virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-transport.cf

where mysql-trasport.cf contains:

select_field = domain
where_field = domain
additional_conditions = and active = 1

I would like to do so that a message is delivered localy only if the
'trasport' for the domain specified by the domain part of the recipient,
is the local server. Otherwise the message have to be forwarded to the
responsible post office server for the recipient domain.

So I have to add the condition:

additional_conditions = and active = 1 and
transport='smtp:host.domain.tld'

where 'host.domain.tld' is the name of local machine.

Now I would like to make safer the lookup table configuration. So I have
thought of modify the additional condition so:

additional_conditions = and active = 1 and LOWER(transport) in
('smtp:`hostname -f`', 'smtp:[`hostname -i`]')

But postfix does not interpolate the shell command..

Is there a way to make safer my lookup condition?

TIA,

rocsca
Reply | Threaded
Open this post in threaded view
|

Re: advanced mysql lookup

mouss-2
Rocco Scappatura wrote:

> Hello,
>
> I would like to add further condition for delivery of email messages.
>
> In my main.cf I have this setting:
>
> virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-transport.cf
>
> where mysql-trasport.cf contains:
>
> select_field = domain
> where_field = domain
> additional_conditions = and active = 1
>
> I would like to do so that a message is delivered localy only if the
> 'trasport' for the domain specified by the domain part of the recipient,
> is the local server. Otherwise the message have to be forwarded to the
> responsible post office server for the recipient domain.
>
> So I have to add the condition:
>
> additional_conditions = and active = 1 and
> transport='smtp:host.domain.tld'
>
> where 'host.domain.tld' is the name of local machine.
>
> Now I would like to make safer the lookup table configuration. So I have
> thought of modify the additional condition so:
>
> additional_conditions = and active = 1 and LOWER(transport) in
> ('smtp:`hostname -f`', 'smtp:[`hostname -i`]')
>
> But postfix does not interpolate the shell command..

no, postfix does not interpret shell, perl, python, php, java, ... code ;-p


>
> Is there a way to make safer my lookup condition?
>

you could try playing with
        SUBSTRING_INDEX(USER(), '@', -1)
but it is safer to use a script (or a makefile) to generate the .cf file
on each machine.