kevinoid / auth-mailbox-joomla

Plugin for Joomla! to authenticate users against a mail server using IMAP, NNTP, or POP3.
GNU General Public License v2.0
6 stars 0 forks source link

Authentication to mailbox server failed: Can't login to this server #8

Closed aklik closed 7 years ago

aklik commented 10 years ago

Hi, I was trying to make it work on my server. From whatever reason I receive the following error: "Authentication to mailbox server failed: Can't login to this server" Any idea what can it be? I ran a telnet test connection on the host against the mailbox server's ports.. everything is ok, but in joomla (using Joomla 3.2.3 version).. nothing..none of the options are working, secured or not secured.. Any hint would be welcomed. Thanks!

kevinoid commented 10 years ago

The error message is saying that the call to imap_open with the configured settings generated the error message Can't login to this server. If you could include the configuration options that you are using (the ones you think are most likely to work), I can show you the call to imap_open that will be used and we can put it in a plain PHP file and troubleshoot from there.

aklik commented 10 years ago

Hi Kevin, thanks for reply.. I was trying to setup as simple as possible so first without any kind of encryption, as you can see in the attached pictures.. screen1 screen2

Also, I would like to know what exactly "create users" option does? Is it creating new joomla user at login for new users which have already an email on the domain.com?

thanks!

kevinoid commented 10 years ago

Yes, you are correct about the "Create users" option. The option has a tooltip on it, but it's still not really clear. I should probably rename that to "Create Joomla! User" or similar.

The configuration you've posted should correspond to the following code in PHP:

<?php
$mailboxStream = imap_open("{10.3.3.2:110/service=pop3/notls/novalidate-cert}", "username", "password", 0);
if ($mailboxStream) {
    print("Connected!");
    imap_close($mailboxStream);
} else {
    print("Failed: " . implode('<br />', imap_errors()));
}
?>

Could you try putting that in a file on your server and visiting the page (after replacing "username" and "password" with valid credentials) and let me know what happens? If it doesn't work, we'll need to figure out what would work (based on the documentation for imap_open).

I just noticed that /novalidate-cert is being included even though it's not using TLS, so I'll have to fix that. If it doesn't work, try removing that as the first attempt.

Thanks!

aklik commented 10 years ago

Kevin, don't worry about "Create users" I didn't go to check the tooltip and it is clear.. just wanted to be sure about it.

As the first attempt I'm receiving in browser the same error message Failed: Can't login to this server . Looking in the apache logs I found the following:

PHP Warning:  imap_open(): Couldn't open stream {10.3.3.2:110/service=pop3/notls} in /var/www/html/test_mail.php on line 2

same problem with or without /novalidate-cert

kevinoid commented 10 years ago

Hmmm. You could try changing the imap_open call to be imap_open("{10.3.3.2:110/service=pop3/notls}", "username", "password", OP_DEBUG); to see if that adds any extra information to the logs. Also, if you can, it may be worth checking the logs on the mail server to see if it logged the connection attempt. Another idea is to get a packet capture using Wireshark to see what the connection looks like (although this is admittedly rather advanced debugging).

Unfortunately, I don't know much about the imap_open internals, particularly for POP3, so I don't have any really good suggestions for what to try next. Sorry about that.

ghost commented 10 years ago

Thought I would chime in here as I had the same issue. Make sure you have php-imap or the php module for pop installed. I received the same error and it was because I did not have php-imap installed and once I did it worked fine. Also to note I have not tried it with POP only with imap.

aklik commented 10 years ago

Hey Mgdale, glad you jumped in, any help is welcomed. I changed to IMAP and I have a new error message: Failed: Can't open mailbox {10.3.3.2:143/service=imap4/notls}: invalid remote specification

Pretty strange that I can't see any error in the logs on the mail server...

kevinoid commented 10 years ago

Thanks for chiming in @mgdale, good idea.

@aklik, I think you would need /service=imap rather than /service=imap4 although I haven't tested whether /service=imap4 works. Of course, that would also depend on your mail server supporting IMAP in addition to POP.

Is it possible that your web server is configured to prevent outbound connections from PHP (e.g. using SELinux or user-specific firewall rules)?

ghost commented 10 years ago

I have to wonder if it is never reaching the imap server. You did check to be sure php-imap is installed? Also try using telnet and logging into the imap server as a user and see if you can connect as this will check your outbound rules just to get to imap.

telnet: > telnet imap.example.com imap telnet: Trying 192.0.2.2... telnet: Connected to imap.example.com. telnet: Escape character is '^]'. server: * OK Dovecot ready. client: a1 LOGIN MyUsername MyPassword server: a1 OK Logged in.

aklik commented 10 years ago

@mgdale yes, php-imap is installed. @kevinoid no selinux active and server can do imap4 as well.

So, I managed to login from php but I had to remove all the securities from dovecot. So login was done with plain text and no ssl. If I'm trying to test it in the same way through joomla, it says that plain text auth is not accepted even if in plugin I set up plain text, no encryption and no ssl. I guess the problem is somewhere around the connection encryption and password encryption.

LE: After more testing, using the php test script I managed to login using:

{10.3.3.2:993/service=imap/ssl/novalidate-cert}

In joomla with the following seetings doesn't work. capture1 capture2

The error message is

Authentication to mailbox server failed: Can't do secure authentication with this server
aklik commented 10 years ago

I'm coming with an update. I'm running the test against different mail server, the imap_open works without problems, more than that when I'm trying to login now using joomla I'm receiving the following error: Warning: You cannot access the private section of this site. also in the mail server's log everything looks ok, so I'm guessing that now it is a joomla issue.. any idea?

ghost commented 10 years ago

Sounds like the user and the site have different groups. Check the new user that was added to see what group they are in then check the page and category to see if it is the same group. If they don't match up, you can change the New Users Reg Group under Users > Options to automatically assign the correct group to new authenticated users. Also in the Options "New User Account Activation" must be set to Self. Oh and manually change the User.

On a side note be sure you turn off "Allow User Registration" if you are not allowing other types of registration.

kevinoid commented 9 years ago

Hi @aklik. Were you ever able to find out the cause of the Warning: You cannot access the private section of this site. error message or to work around it? Issue #9 includes a similar message and I've been unable to reproduce it. Just wondering if you might have had any success since March.

kevinoid commented 7 years ago

I ran into the Warning: You cannot access the private section of this site. message and tracked it down to an autoregistration failure. In my case autoregistration was failing because the username with the configured domain appended did not pass Joomla's internal email address validation, causing the user creation to fail.

If you (or anyone else) runs into a similar error message and the user does not appear in User Management, you can check if this is the cause by changing the log statement at plugins/user/joomla/joomla.php:364 to read:

JLog::add('Error in autoregistration for user ' . $user['username'] . ': ' . $instance->getError() . '.', JLog::WARNING, 'jerror');

Changing 'error' to 'jerror' will cause the error to be displayed to the user and adding $instance->getError() will get the error which occurred during the user save attempt. Feel free to reopen this issue or create another one with the additional warning information.