[imp] imp_expand_fromaddress behaves strange

Antoine Jacoutot ajacoutot at lphp.org
Fri Jun 4 09:45:32 PDT 2004


Hi :)

I'm having a very strange problem using the standard imp_expand_fromaddress 
function in imp.
I use ldap to store my sendmail maps so I though I could use the entries in it 
to get imp users email address.

This is the function I use:

 if (!function_exists('imp_expand_fromaddress')) {
     function imp_expand_fromaddress($imp) {
        $ldapServer = 'localhost';
        $ldapPort = '389';
        $searchBase = 'dc=domain,dc=com';

        $ds = @ldap_connect($ldapServer, $ldapPort);

        $searchResult = @ldap_search($ds, $searchBase, 
'sendmailMTAMapValue=' . $imp['user']);
        $information = @ldap_get_entries($ds, $searchResult);
        $name = $information[0]['sendmailMTAKey'][0];

        ldap_close($ds);

        return (empty($name) ? $imp['user'] : $name);
     }
 }
 
Unfortunately, it does not work :(
I get: <testuser at .SYNTAX-ERROR.> as from address...

In command line, it works:
$ ldapsearch -LLL "(sendmailMTAMapValue=testuser)" sendmailMTAKey
dn: sendmailMTAKey=testuser at otherdomain.com,dc=domain,dc=com
sendmailMTAKey: test at otherdomain.com

Now, the strange part: if I create a dummy user in the form 
uid=testuser,dc=domain,dc=com (objectclass inetorgperson) with a mail 
attribute, and after changing back 'sendmailMTAMapValue=' to 'uid=' and 
'sendmailMTAKey' to 'email' in the imp_expand_fromaddress function, then it 
works !!!

There must be something I do not understand, but what ?
I've been trying to find a way to resolv this for days and did not came up 
with any explanation.
I could really use some help :)

Thanks in advance.
Regards,

Antoine


More information about the imp mailing list