[imp] Forcing an identity/from address

Andrew Morgan morgan at orst.edu
Thu Jul 29 13:45:40 PDT 2004



On Wed, 28 Jul 2004, Andrew Morgan wrote:

> On Wed, 28 Jul 2004, Jan Schneider wrote:
>
> > Zitat von Andrew Morgan <morgan at orst.edu>:
> >
> > > I have IMP v3.2.2 configured so that my users cannot set their From:
> > > address (trouble-maker students!) as follows in imp/config/prefs.php:
> > >
> > > $_prefs['from_addr'] = array(
> > >     'value' => '',
> > >     'locked' => true,
> > >     'shared' => true,
> > >     'type' => 'implicit'
> > > );
> > >
> > > With this, the From: address is built from the username and realm, and
> > > this works great.
> > >
> > > However, I'd like to specifically set an alternate From: address for a
> > > small number of users.  We would like to migrate them from an old email
> > > system onto ours, but it is important that their outgoing email address be
> > > the same as before.
> > >
> > > I tried temporarily remove the lock on from_addr, setting an email
> > > address, then setting the from_addr lock again.  The From: address worked
> > > when I removed the lock, but once I locked the preference again, it went
> > > back to username at realm.  I guess the code overrides the saved From:
> > > address when the preference is locked?
> >
> > It should not, but identities are a very special case of preferences.
> >
> > > Is that the way it is supposed to work?  Is there some other way to handle
> > > this inside IMP short of modifying the code?
> >
> > Use a from_addr hook in conf.php.
>
> For a small number of users, would a simple php array be ok for this?  I
> don't really want to go to the hassle of making a table in mysql for it...
> :)  Just asking for some advice here.

Here is what I ended up doing, in case anyone else wants to know.

In imp/config/conf.php:
-----------------------
$conf['hooks']['from'] = 'imp_expand_fromaddress';

if (!function_exists('imp_expand_fromaddress')) {
        function imp_expand_fromaddress($imp) {
                include 'from_map.php';
                $from = $from_map[$imp['uniquser']];
                return (empty($from) ? $imp['user'] : $from);
        }
}
-----------------------

and a new file I created, imp/config/from_map.php:
-----------------------
<?php

$from_map = array(
                "morgan at onid.orst.edu" => "morgan at orst.edu"
                );

?>
-----------------------

I'll be adding more entries to the array for this migration, and this
seems pretty simple and flexible.

	Andy


More information about the imp mailing list