RE: [Exim] Multiple domain aliasses via MySQL

Pàgina inicial
Delete this message
Reply to this message
Autor: Mark McRitchie
Data:  
A: 'Cipriano Groenendal'
CC: Exim Users (E-mail)
Assumpte: RE: [Exim] Multiple domain aliasses via MySQL
Try changing the *'s to % which is the mysql wildcard character and your sql
to this:

SELECT user FROM tblAliases
WHERE
(alias = '${quote_mysql:$local_part}' OR '${quote_mysql:$local_part}' like
alias)
AND
domain='${quote_mysql:$domain}'

the order of the parts in like is important as the pattern has to be the
second part.

Plus some random sql as an example ;-)

Regards,
Mark.

mysql> select * from thing;
+---+---+
| a | b |

+---+---+
| 1 | % |
| 2 | % |
| 2 | f |

+---+---+
3 rows in set (0.01 sec)

mysql> select * from thing where b='%';
+---+---+
| a | b |

+---+---+
| 1 | % |
| 2 | % |

+---+---+
2 rows in set (0.01 sec)

mysql> select * from thing where b like '%';
+---+---+
| a | b |

+---+---+
| 1 | % |
| 2 | % |
| 2 | f |

+---+---+
3 rows in set (0.01 sec)


mysql> select * from thing where a like b and a=2;
+---+---+
| a | b |

+---+---+
| 2 | % |

+---+---+
1 row in set (0.00 sec)


mysql> select * from thing where (b='foo' or 'foo' like b) AND a=2 ;
+---+---+
| a | b |

+---+---+
| 2 | % |

+---+---+
1 row in set (0.00 sec)


-----Original Message-----
From: Cipriano Groenendal [mailto:cipri@ezlinux.nl]

Hello List.

For the past few days I've been trying to get MySQL based aliases to work.
My idea was that, since I'll be hosting multiple domains for customers, I'd
create a MySQL database and do lookups via that. I created a database that
looks roughly like this:

+-------+------------+--------+------+
| alias | domain     | user   | uid  |

+-------+------------+--------+------+
| *     | cipri.com  | cipri  | 2000 |
| *     | cerala.com | cerala | 2001 |

+-------+------------+--------+------+

And I created this Director:

mysql_aliases:
driver = aliasfile
file_transport = address_file
pipe_transport = address_pipe
transport = local_delivery
no_more
search_type = mysql
query = "SELECT tblAliases.user FROM tblAliases WHERE \
( \
(tblAliases.alias='$local_part' && tblAliases.domain='$domain' ) \
OR \
(tblAliases.alias='*' && tblAliases.domain='$domain' ) \
) \
LIMIT 1"


When I run exim -d9 -bt cipri@???, and run the SQL statement manually
I get back a single value of `cipri`, which is where it should be delivered
to. However, when I try a random address this happens:


# exim -bt foobar@???
foobar@???
deliver to foobar in domain cipri.com
director = mysql_aliases, transport = local_delivery


Salamis Group of Companies - WWW.SALAMISGROUP.COM

This communication contains information which is confidential and may
also be privileged. It is for the exclusive use of the intended
recipient(s). If you are not the intended recipient(s) be advised
that any form of distribution, copying or use of this communication
or the information it contains is strictly prohibited and may be
unlawful. We apologise if you have received this communication in
error. Please return it to the sender immediately, delete this
communication from your computer and destroy any copies of it. Any
views/opinions expressed in this email are that of the author and may
not reflect the views of Salamis (M&I)Ltd.