Some hints for Horde IMP with ISPConfig

Discussion in 'Tips/Tricks/Mods' started by hastlaug, Apr 17, 2006.

  1. hastlaug

    hastlaug New Member

    Although this post seems long: Read it - it's (almost) just copy and paste in 2 positions. No big changes. Don't be afraid :)

    If you setup Horde IMP as webmailer, you might want to have the sender mail address and the sender name correctly be set.

    That's not that easy because you need (non-existing) hook functions retrieving the data. But as I wrote such functions for me, you don't need to do this again ;)

    First locate the horde config files.
    In horde3/config/prefs.php change the following:

    Code:
    $_prefs['fullname'] = array(
        'value' => '',
        'locked' => false,
        'shared' => true,
        'type' => 'text',
        'hook' => true,
        'desc' => _("Your full name:")
    );
    
    $_prefs['from_addr'] = array(
        'value' => '',
        'locked' => true,
        'shared' => true,
        'type' => 'text',
        'hook' => true,
        'desc' =>  _("Your From: address:")
    );
    
    Especially 'hook' has to be true. I suggest setting 'locked' of 'from_addr' to true if you don't want users to be able to modify their from-address.

    Then you have to add the following to your horde3/config/hooks.php:

    Code:
    if (!function_exists('_prefs_hook_from_addr')) {
      function _prefs_hook_from_addr($user=null) {
        $dsn = 'mysql://sqluser:sqlpass@localhost/db_ispconfig';
    
        if (is_null($user)) {
          $user = Auth::getAuth();
        }
    
        $db =& DB::connect($dsn, true);
        if (PEAR::isError($db)) {
          return $user;
        }
    
        $query  = 'SELECT user_email,domain_domain FROM (isp_isp_user INNER JOIN isp_dep ON (isp_isp_user.doc_id=child_doc_id AND isp_isp_user.doctype_id=child_doctype_id))';
        $query .= ' INNER JOIN isp_isp_domain ON (parent_doc_id=isp_isp_domain.doc_id AND parent_doctype_id=isp_isp_domain.doctype_id) WHERE user_username=' . $db->quote($user);
        $result =& $db->query($query);
    
        if ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
          $return = $row['user_email'] . "@" . $row['domain_domain'];
        } else {
          $return = $query;
        }
    
        $db->disconnect();
    
        return $return;
      }
    }
    
    if (!function_exists('_prefs_hook_fullname')) {
      function _prefs_hook_fullname($user=null) {
        $dsn = 'mysql://sqluser:sqlpass@localhost/db_ispconfig';
    
        if (is_null($user)) {
          $user = Auth::getAuth();
        }
    
        $db =& DB::connect($dsn, true);
        if (PEAR::isError($db)) {
          return $user;
        }
    
        $query = 'SELECT * FROM isp_isp_user WHERE user_username=' . $db->quote($user);
        $result =& $db->query($query);
    
        if ($result->fetchInto($row, DB_FETCHMODE_ASSOC)) {
          $return = $row['user_name'];
        } else {
          $return = $user;
        }
    
        $db->disconnect();
    
        return $return;
      }
    }
    Make sure you replace sqluser by your sql user with sufficient rights to query the ispconfig database and replace sqlpassword by its password. Maybe you also want to replace localhost by the correct sql server and db_ispconfig by the correct sql database. Please note that you have these changes TWO times in the code above.

    Done ;)
     
    Last edited: Apr 18, 2006
  2. Cirox

    Cirox New Member

    Hi,

    thx for your hints.

    greetings cirox
     
  3. SupuS

    SupuS Member HowtoForge Supporter

    Hi

    I have mysql 5 and horde 3.1.2 and your script doesn't work for me as it should .. sql query:

    Code:
    $query  = 'SELECT user_email,domain_domain FROM (isp_isp_user INNER JOIN isp_dep ON (isp_isp_user.doc_id=child_doc_id AND isp_isp_user.doctype_id=child_doctype_id))';
        $query .= ' INNER JOIN isp_isp_domain ON (parent_doc_id=isp_isp_domain.doc_id AND parent_doctype_id=isp_isp_domain.doctype_id) WHERE user_username=' . $db->quote($user);
        $result =& $db->query($query);
    returns 0 rows so if I want to send mail I see this query instead of email adress. :eek:

    I'm not so good in sql lang and I am not able to find the thing what can resolve this problem. Any hints please?

    Little note: in new version of horde I had to add

    Code:
    require_once 'DB.php';
    before

    Code:
    $db =& DB::connect($dsn, true);
     
  4. johnquilmes

    johnquilmes New Member

    Horde Groupware Webmail Edition

    are you probe Horde Groupware Webmail Edition and install with ispconfig??

    help my.. please,...!!:confused:
     
  5. mthalmei

    mthalmei New Member

    Thanks for this great hook.

    But unfortunately as already written above this does not seem to be working with recent versions of horde and ispconfig.

    I have investigated a little bit and found that by using the table isp_isp_web instead of isp_isp_domain this seems to work.

    The code schould look like this:
    PHP:
    $query  'SELECT user_email,web_domain FROM (isp_isp_user INNER JOIN isp_dep ON (isp_isp_user.doc_id=child_doc_id AND isp_isp_user.doctype_id=child_doctype_id))';
    $query .= ' INNER JOIN isp_isp_web ON (parent_doc_id=isp_isp_web.doc_id AND parent_doctype_id=isp_isp_web.doctype_id) WHERE user_username=' $db->quote($user);

    ...

    $return $row['user_email'] . "@" $row['web_domain'];
     
  6. whitlebitle

    whitlebitle New Member

    Is horde works with ISPCONFIG without a problem ?
     
  7. gorni

    gorni New Member

    Yes, Horde Groupware Webmail Edition 1.1 RC2 perfectly works out of the box on ISPConfig 2.2.21. And also does the hooks mentionned above, with Mthalmei's patch...
     
  8. whitlebitle

    whitlebitle New Member

    Thank you!

    Where to download it and how to setup it to be like www.domain.com/webmail

    like it is with uebimiau direct to domain.com/webmail

    And is it possible to be setup without https like it is with packagaes: uebimiau and squirremail?
     
  9. gorni

    gorni New Member

    You may download it from the Horde website at http://www.horde.org.

    It just installs like any other PHP/MySQL web application on ISPConfig. Horde specific installation instructions are bundled in the package.

    Horde will act like any ISPConfig site: you may or may not activate SSL (https) on it, at your convenience.
     
  10. whitlebitle

    whitlebitle New Member

    Gorni,

    Thank you very much.

    On additional question: Does 2008-02-15: Horde Groupware Webmail Edition 1.0.5
    works great as well on ispconfig ?
     
  11. gorni

    gorni New Member

    Yes, I guess: I successfully installed 1.0.4 before switching to 1.1 RC2, and I don't see any reason for the 1.0.5 (bugfix) release not to work as well...
     
  12. Sheridan

    Sheridan New Member

    Sorry for bringing that thread up again, but was anyone able to configure horde so that you can log in using the mail address instead of the username?

    With squirrelmail everything works fine, but i don't get this with horde. :-(

    Thanks.
     

Share This Page