Mailboxes Auto Login for ispconfog administrators

Discussion in 'Tips/Tricks/Mods' started by adammazin, Oct 4, 2019.

  1. adammazin

    adammazin New Member

    Hello guys,
    finally i got it work, I'm not programmer so i hope programmers help make it easier for others. i did it because my clients was nagging since i moved them from Cpanel to awesome Ispconfig to give them ability for auto login to other mailboxes without remembering or resetting mailbox passwords. so steps like below:
    Step One: create dovecot master password following these instructions: https://wiki1.dovecot.org/Authentication/MasterUsers
    changes will be done here /etc/dovecot/dovecot.conf
    like below:
    PHP:
    auth_master_user_separator = :
    passdb {
        
    args = /etc/dovecot/dovecot-master-users
        master 
    yes
        pass 
    yes
        driver 
    passwd-file
      
    }
    you can use another separators as you like " _ , - , +" just don't use "*"
    and you have to create this file /etc/dovecot/dovecot-master-users and but master password inside like below
    Code:
    admin:{SSHA512}PUTMdnfsflskjdctsLobSmGEndfklsdjk9WSaiHnudjflksjdskjsF2eJkjdhsddjslkdfjlV/BbSJ5M3BXOChEpo=
    to create master password like above use this CLI command
    Code:
    doveadm pw -s SSHA512
    keep in mind this text {SSHA512} is important read instruction.
    don't forget to restart dovecot
    Code:
    service dovecot restart
    keep this password save or simply don't keep it on your PC use it and forget it, if anyone got them you and your clients will be hacked :D
    before i forget change file permission
    Code:
    chown root:dovecot /etc/dovecot/dovecot-master-users
    chmod 644 /etc/dovecot/dovecot-master-users
    Step Two: you have to play with ispconfig files :rolleyes: so go and add below lines to /var/www/ispconfig/mail/webmailer.php after line 59 and right after
    Code:
           $webmail_url = str_replace('[SERVERNAME]', $serverData['server_name'], $webmail_url);
    
    lines to add:
    Code:
    include "/var/www/ispconfig/mail/RoundcubeLogin.class.php";
    $dbemail = $app->db->queryOneRecord("SELECT email FROM mail_user WHERE mailuser_id = ?", $emailId);
    $rcl = new RoundcubeLogin("/roundcube/", $debug);
    $rcl->setHostname($serverData['server_name']);
    $rcl->setPort(80);
    $rcl->setSSL(false);
    $rcl->logout();
    try {
            $rcl->login($dbemail['email'].":admin", "Your PLAIN Password");
            $rcl->redirect();
    }
    catch (RoundcubeLoginException $ex) {
     echo "ERROR: Technical problem, ".$ex->getMessage();}
    
    and replace "Your PLAIN Password" on above code with your plain master password you created earlier, remember plain not encrypted. and you have to comment out this line
    Code:
    //      header('Location:' . $webmail_url);
    Then go and create this file /var/www/ispconfig/mail/RoundcubeLogin.class.php on same directory like you see, fill it with code from this file https://blog.heckel.io/wp-content/uploads/2008/05/RoundcubeLogin.class.php.txt or or just download file and upload it to above directory.
    ***All thanks after Brilliant Ispconfig Team to this guy Philipp C. Heckel and his script find it here: https://blog.heckel.io/2008/05/16/roundcube-login-via-php-script/
    after creating it don't forget to change file permission:
    Code:
    chown -R ispconfig:ispconfig /var/www/ispconfig/mail/RoundcubeLogin.class.php

    Now go and test your new feature ;)
     
    Last edited: Nov 15, 2019
    ahrasis, recin and Jesse Norell like this.
  2. recin

    recin Member

    Thanks. It works like a charm.
    Only 2 notes:
    • You dont need -R when doing chown to a file
    • When adding lines to ispconfig webmailer.php file, note you can't do it in the end of the file, they should be before the exit in the last line
     
  3. recin

    recin Member

    After step one, you could try if it works accessing webmail with any mail created followed by :admin and the plain master password
     
  4. adammazin

    adammazin New Member

    thank you for replying and helpful comments, you are right , i did edit the post
     
  5. adammazin

    adammazin New Member

    ya it work, test it by yourself
     
  6. recin

    recin Member

    I wanted to mean you could add this info in the original post, just to be sure that the postfix password is OK before start playing with ispconfig files.

    On the other hand, how could we keep this changes after ispconfig upgrades?
     
  7. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Use Internet Search Engines with
    Code:
    site:howtoforge.com ispconfig conf-custom
     
    adammazin likes this.

Share This Page