[Exim] LDAP-based mailing lists - solved

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Matthew Palmer
Datum:  
To: exim-users
Betreff: [Exim] LDAP-based mailing lists - solved
As regards my previous mail, with the help of Tamas Tevesz I've got what I
wanted going (more or less). For posterity's sake, I present my
implementation for archival and comment:

MAIN:

perl_startup = do '/etc/exim/subs.pl'

DIRECTORS:

all_members:
driver = smartuser
local_parts = all_members
rewrite = false
new_address = ${perl {all_members}}
senders = <colon separated list of authorised e-mail addresses>

And the script I used (/etc/exim/subs.pl):

#!/usr/bin/perl -w

use strict;

use Net::LDAP ':all';

my $ldapserver = "ldap";
my $basedn = "ou=people,dc=local,dc=domain,dc=tld";
my $userfilter = "(objectclass=posixaccount)";

sub all_members()
{
    my $ds = Net::LDAP->new($ldapserver);
    $ds->bind();
    my $data = $ds->search(
        base => $basedn,
        filter => $userfilter,
        attrs => [ "mail" ]);


    my @addrlist;
    for (my $i = 0; $i < $data->count; $i++) {
        my $user = $data->entry($i);
        my $addr = $user->get_value("mail");
        if ($addr) {
            push(@addrlist, $addr);
        }
    }


    return join(", ", @addrlist);
}


This can, of course, be used as the basis for a completely LDAP-based
mailing list management system (which may be a project for a future time).


--
-----------------------------------------------------------------------
#include <disclaimer.h>
Matthew Palmer
mjp16@???