Authenticating with several IMAP servers

Authenticating with several IMAP servers

by Sebastian Bitzer -
Number of replies: 6

Hi,

my university uses two mail system. A new one and one which is slowly phased out. Both have separate IMAP servers. This means that part of my students can authenticate through one server the other part through the other server. I could not find an option for using two IMAP servers for authentication in Moodle. Is this possible at all? If yes, how?

Thanks a lot!

Average of ratings: -
In reply to Sebastian Bitzer

Re: Authenticating with several IMAP servers

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

You can only use one but you only need to use one.  Students do not authenticate with the imap server - they do not receive email through moodle.  Moodle just uses one smtp server to send email out.  All Moodle messaging is handled internally.

In reply to Emma Richardson

Re: Authenticating with several IMAP servers

by Sebastian Bitzer -

Thanks for your reply. Just to clarify: My question was purely about authentication methods. I want to make it easy for students to log into the site by not requiring them to remember a new password. IMAP authentication works great for that purpose and is easy to set up. My problem is just that I have two sets of students who are users of two different IMAP servers.

In reply to Sebastian Bitzer

Re: Authenticating with several IMAP servers

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Oh, got it.  Sorry -never actually seen any questions about imap authentication and didn't realize it was an option.  However, I would guess what you will need to do is duplicate the imap authentication plugin and call it something else like imap2.  You might search on clone ldap which will give you some ideas.  Basically you copy the folder but then have to go through the files and change imap to imap2 - then you should be able to install the second plugin and set it up to your second imap server.

In reply to Emma Richardson

Re: Authenticating with several IMAP servers

by Sebastian Bitzer -

Ok, thanks. I had a quick go at this, copied the auth/imap folder into auth/imap2 and tried to change occurrences of the plugin name in the files in the imap2 folder. The latter part is not so easy, because it's unclear what refers to the plugin name and what is part of imap settings without some background knowledge of the code. Anyway, the copied plugin doesn't show up in the list of authentication methods at all. Do I miss something? Is it likely that I missed an occurrence of the plugin name and that's why it only shows the original plugin?

In reply to Sebastian Bitzer

Re: Authenticating with several IMAP servers

by Sebastian Bitzer -

Oh, never mind. Moodle apparently just took a while to recognise the new plugin. At some point it showed me an install dialogue after which 'imap2' was listed. It works now. This is what I changed (Moodle 2.8.8):

db/install.php:

- rename function

version.php:

- $plugin->component = 'auth_imap2';

lang/en/auth_imap.php:

- rename file to auth_imap2.php

- string['pluginname'] = 'IMAP server 2';

- rename $string['auth_imap2description']

config.html:

- replace occurrences of 'auth_imap' with 'auth_imap2'

auth.php:

- class auth_plugin_imap2 extends auth_plugin_base {

- function auth_plugin_imap2() {
        $this->authtype = 'imap2';
        $this->config = get_config('auth/imap2');
    }

- replace occurrences of auth/imap with auth/imap2


As I said, authentication with two IMAP servers appears to work now. The only thing I couldn't get to work is the auth_imap2description string. On the config-page for the imap2 plugin it just shows "auth_imap2description" (there are two square brackets around the string, in case the moodle editor replaces them again with a link).


Good luck!

In reply to Sebastian Bitzer

Re: Authenticating with several IMAP servers

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Glad you got it working.  Not sure about the string...must be a line in there somewhere that you should be able to change.  Good luck.