[imp] Virtual domains & Multiple domains (popaccount toname.surname)

Tim Gorter email@teletechnics.com
Thu, 8 Aug 2002 17:40:22 +0200


Try this, see if it works for you. I work of a file called virtmaps, I do
not know if the layout is the same for you. It assumes that the file on the
left has the full email address, and on the right the local username,
seperated by plain spaces. the virtmaps being a plain text file.

Note. It takes the full email address! meaning full.name@domain.name will
be returned to IMP. This also means that you can use one static login page,
and the users return address will be the domain name as mentioned in the
virtmaps file. Also note that this function will override any setting the
user may place in his options.

Hope it helps.


if (!function_exists('imp_expand_fromaddress')) {
    function imp_expand_fromaddress($imp) {
        $file = '/etc/virtmaps';
        $uname = $imp['user'];

        if (is_file($file)) {
            $fcontents = file($file);
            $virtline = preg_grep("[$uname]", $fcontents);
            $virtline = (array_values($virtline));
            $uname = substr("$virtline[0]",0,strpos("$virtline[0]", " "));
            if ($uname == '') $uname = $imp['user'];
        } else {
            $uname = $imp['user'];
        }
        return (empty($uname) ? $imp['user'] : $uname);
    }
}

Wednesday, August 7, 2002, 3:06:59 PM, you (Antti) wrote:

AL> Hi,

AL> Proper function would do the trick.. but unfortunately PHP is not one of my
AL> main areas.. any ready, anyone? This function should be pretty simple; it
AL> should just check /etc/mail/virtusertable for the popaccount given from the
AL> login-form and then change it to what.ever@address.com (and removes
AL> @address.com)