Re: [EXIM] Mysql and exim

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Malcolm Beattie
Dátum:  
Címzett: exim-users
Tárgy: Re: [EXIM] Mysql and exim
Paul Mansfield writes:
> On Wed, 28 Oct 1998, iqbal wrote:
> > I've trawled through all th archives (well most of them) and come across
> > a few articles relating to exim and Mysql linking up, has there ever
> > been a solution to this , or will there ever be.
>
> The only thing I can think of is to use the Perlified Exim and then use the
> Perl-to-MySql package, see http://www.cpan.org
>
> My guess is that the perl hooks in Exim might be a very productive route to
> getting all sorts of interesting add-ons to Exim rather than bloat Exim.


The latest patch is now available as
    ftp://ftp.ox.ac.uk/pub/perl/exim-perl-0.5.patch


You'd probably want something like

/etc/exim.pl:

    use DBI;
    $dbh = DBI->connect("dbi:mSQL:dbname=foo");
    sub find_address {
        my ($local, $domain) = @_;
        return $dbh->selectrow_array(
            "select address where local = '$local' and domain = '$domain'"
        );
    }


exim.conf:

    perl_startup = do '/etc/exim.pl';
    ...
    # directors
    mysql_lookup:
      driver = smartuser
      new_address = ${perl{find_address}{$local_part}{$domain}}



Thinking about it, I suspect we want exim to finish off the embedded
perl cleanly so that you can add an END block
    END { $dbh->disconnect }
Although it's not vital in this case, it's probably something which
will be needed at some time or other.


Others have already mentioned their suggestions as to why you might
not want to use a central database directly (and there's certainly
the overhead of a new db connection every time exim is run to
consider) but this, at least, is one way to do it if you so decide.

--Malcolm

--
Malcolm Beattie <mbeattie@???>
Unix Systems Programmer
Oxford University Computing Services

--
*** Exim information can be found at http://www.exim.org/ ***