[imp] Utilizing the Generics Table

Benjamin J. Higgins bhiggins@dovetailinternet.com
Thu, 30 Aug 2001 13:34:33 -0400


 >>  >>  Probably - couldn't you stick this in the from hook
 >>  >>  ($conf['hooks']['from'])?
 >>  Probably . . . however this is ween-myself-off-caffeine and I'm gittery
 >>  and can't think straight . . . I'll take a look and see if I can figure
 >>  it out and (maybe) give you something you can commit to the CVS tree. . .
 >>  Thanks!

If anyone is interested, here's the code I came up with for =
($conf['hooks']['from']).  It will compare the $imp['user'] against the =
genericstable of SendMail and return the email address related to the username =
(as written in the /etc/mail/genericstable text file NOT the makemap file), or =
will return the username if not found.

 if (!function_exists('imp_expand_fromaddress')) {
     function imp_expand_fromaddress ($imp) {
        // get contents of the SendMail generics table

        $filename =3D "/etc/mail/genericstable";
        $fd =3D fopen ($filename, "r");

        while (!feof ($fd)) {
                $buffer =3D fgets($fd, 4096);
                $buffer=3Dstr_replace(chr(10),"",$buffer);
                $buffer=3Dstr_replace(chr(13),"",$buffer);
                $buffer2 =3D split("[     ]+", $buffer);
                if ($buffer2[0] =3D=3D $imp['user']) {
                        fclose ($fd);
                        return $buffer2[1];
                }
        }

        fclose ($fd);
        return $imp['user'];
     }
 }

--
Ben Higgins          |      Dovetail Internet Technologies, LLC
906 Boston Turnpike  |         "Internet Solutions That Fit"
Shrewsbury, MA 01545 |  Phone: (508) 845-6465    FAX: (508) 845-6447