[imp] Re: Réf. : Default From Address for new users

Kevin Myer kevin_myer at iu13.org
Sat Apr 2 07:36:19 PST 2005


You need to write a function called _prefs_horde_expand_from_addr in
horde/conf/hooks.php that returns the result you want (for Horde 3.X).  
I'm not
sure what version you're using if you have a hooks.php file in imp/conf 
but you
should be able to adapt this, to that version.

In horde/conf/prefs.php, find the preference you want to set by default
(from_addr) and add the following line at the end of that section:
'hook' => 'true'

So it looks like:
// user full name for From: line
$_prefs['from_addr'] = array(
    'value' => '',
    'locked' => true, //Lock this if you don't want them to change it
    'shared' => true,
    'type' => 'text',
    'desc' => _("Your From: addresses:"),
    'hook' => true
);


That way, when a user first logs in and their default preferences are 
being set,
the function you wrote in the hooks file will be called to return the result
you want, not whatever the Horde defaults are.

For the specific situation of converting john.example.com, you'll just need to
write a function that replaces the first "." between john and example 
with an @
sign.

For Horde 3.X:
if (!function_exists('_prefs_hook_from_addr')) {

   function _prefs_hook_from_addr($user = null)
// splits off the first part of the name, inserts an @ sign and fills in the
// rest of the domain
// Probably could also do just $fromaddr = strtok($user,"."); and let
// IMP/Horde handle the domain

$fromaddr = strtok($user,".") . "@" . $strtok("");
return $fromaddr;
}

If you name your function imp_expand_fromaddress, just
s/_prefs_hook_from_addr/imp_expand_fromaddress/.

No warranties that the code is right but it should get you the result you want
with a little hacking (but don't blame me if it destroys your Horde install :)

Kevin


Quoting emmanuelbiennier at virtualvercors.net:

> Hi I have the same problem and I don't find the solution BUT I think that
> you can see a function in this file
>
> imp/config/conf.php
>
> the  "imp_expand_fromaddress" function (line 237 in my file)
>
> you can see comments I think that you must activate this function
>
> $conf['hooks']['from'] = 'imp_expand_fromaddress';
>
> /* Here is an example imp_expand_fromaddress function.  You get passed the
> * $imp array and have access to everything inside it, which should be
> * plenty of information.  You can "global" anything else you need. Return
> * an address - either just the user@ side or a full address - and it will
> * be used.
> *
> * NB: If users are allowed to change their fromaddresses (not fullnames,
> * though), and they have one set, this will be overridden.
> *
> * NB2: The code assumes that this function will return a reasonable
> * address, so make sure to fall back to $imp['user'] or some such on
> * failure.
> */
>
> I hope that you can find a solution and post it in the mailing list
>
>
>
>
>
>
>
> "Binda Marco" <M.Binda at datasiel.net>
> Envoyé par : imp-bounces at lists.horde.org
> 01/04/2005 15:29
>
>
>        Pour :  <imp at lists.horde.org>
>        cc :
>        Objet : [imp] Default From Address for new users
>
>
> Hi all,
>
> can anyone tell me how to set a default from address  to webmail users ?
> My email server has Postfix smtp, Cyrus Imap, IMP webmail.
> New users are created with webcyradm.
>
> Users access the webmail with the Cyrus user and password
>
> username  has the form:
>
> user.domain   (it's the cyrus user)
>
> (john.example.com)
>
> If I don't set the from addr (empty by default) in the personal default
> identity , and send a mail,
> the receiver think my email address is:
>
> user.domain at domain
> (john.example.com at example.com)
>
> I need it to become:
>
> user at domain
> (john at example.com)
>
> I tried to look inside the configuration files prefs.php and conf.php but
> I am a newbie
> and can't find a documentation about Imp configuration
>
> How cal I set the adrress "From:" in the  default identity of new users
> (when not already set) ?
>
> Where can I find an in depth documentation on how to configure  IMP ?
>
> Thanks in advance.
> Marco.
> --
> IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe at lists.horde.org
>
>
>
> --
> IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe at lists.horde.org
>



-- 
Kevin M. Myer
Senior Systems Administrator
Lancaster-Lebanon Intermediate Unit 13
(717) 560-6140



More information about the imp mailing list