[imp] unix usernames

Jens Wahnes wahnes at uni-koeln.de
Wed Jul 12 13:01:12 UTC 2017


Maurício José T. Tecles wrote:

> Citando ESSAISSI <remi at remi.lu>:
> 
>> my email server uses unix usernames, hence, my username for smtp
>>  is in my case remi, and for imap too actually
>>
>>  so when i try to send an email, imp complains about not having a
>>  domain name in my usename for sending -- i try to send to a
>> regular
>>  email address with a domain name and the @ ...
>>
>>
>>  this problem is blocking.
>>
> 
> You must configure imp/backends.local.php 'maildomain' with your domain 
> name. Also, configure in your "Preferences" -> "Global Preferences" -> 
> "Presonal Information" your email address.

As administrator, you may wish to set the from_addr preference for all 
users via a hook so they don't have to do it.  Depending on your setup, 
this may be easy or more difficult to do.  If all user's email addresses 
are formed the same way, i.e. username at domain.com, that's fairly easy to 
accomplish.  It may get a bit more complicated if they use different 
domain names or the actual address associated with a certain username 
must be looked up from an LDAP server or database or such because they 
are all different or change dynamically by time.

In the easy case, you may do this by editing .../config/prefs.local.php 
to contain a line like this:


<?php
$_prefs['from_addr']['hook'] = true;


Then, in .../config/hooks.php add something to the effect of


<?php

class Horde_Hooks
{

     const MY_MAIL_DOMAIN = 'example.com'; # replace with your own

     public function prefs_init($pref, $value, $username, $scope_ob)
     {
       // This hook receives the preference name, preference value, 
username, and
       // the master scope object (Horde_Prefs_Scope) as parameters and 
uses the
       // return value from the hook as the new preference value.
       //
       // Username will be null if the user is not authenticated.
	
	  if (strlen($username) && $pref == 'from_addr') {
	    $email = $username . '@' . Horde_Hooks::MY_MAIL_DOMAIN;
		return $email;
	  }
	
	  return $value; // just as a safeguard
	
	}
}


That should do the trick.

Another way would be to have the mail server (SMTP) "canonify" email 
addresses that are lacking a domain, if the SMTP server software has got 
an option to do so.  Of course, that is viable only if you are in charge 
of the SMTP server, too.


Jens


More information about the imp mailing list