Author Topic: Failed to connect to remote host when trying to save remote IMAP  (Read 8275 times)

Offline hukoeth

  • Newbie
  • *
  • Posts: 2
Failed to connect to remote host when trying to save remote IMAP
« on: September 21, 2009, 05:03:23 AM »
Hi,
I searched the forum but could not find a solution to my problem so I hope someone can hope.
This weekend I switched from a different webmailer to Roundcube and installed the account plugin to connect to different IMAP mailboxes which are all hosted on the same server that also hosts my roundcubce installation.

I have no problem logging in to the IMAP accounts directly but when I try to set up a remote imap account I get the error "Failed to connect to remote host".

I tried using the IMAP_OPEN PHP function to connect to localhost and indeed this fails (although I had a webmailer that uses the PHP IMAP extension).

Does anyone have an idea what else I can try to troubleshoot this?

Thanks,
Uli

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Failed to connect to remote host when trying to save remote IMAP
« Reply #1 on: September 21, 2009, 07:00:46 AM »
Can setup a test account for me and give me ftp access to roundcube folder? PM'me details ...
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Failed to connect to remote host when trying to save remote IMAP
« Reply #2 on: September 22, 2009, 04:34:05 AM »
Thanks to ren1809 - which gave me remote access to his server - the problem could be tracked down. The imap_open failure is related to self-signed certificates (http://bugs.php.net/bug.php?id=20605). We have to use "/novalidate-cert" flag in the "test_connection" part of the plugin.

But I'm not sure if this is a general solution or if I should make it optional.

Can anyone tell me if I may fix it by simply adding the "novalidate-cert" flag or is it likely that the "novalidat-cert" flag cause problems on other environments? I have tested it on my server an remotely on ren1809's server. Both worked fine.


  
function test_connection($username,$password,$imap_host,$imap_port,$prot){
    if(
function_exists("imap_open")){
      
$rcmail rcmail::get_instance();
      
$password $rcmail->decrypt($password);
      if(
$prot){
        
$imap_open "{" $imap_host ":" $imap_port "/imap/" $prot "/novalidate-cert}INBOX";
      }
      else{
        
$imap_open "{" $imap_host ":" $imap_port "/novalidate-cert}INBOX";
      }
      if(
$res = @imap_open($imap_open$username$password)){
        
$success true;
        
imap_close($res);
      }
      else{
        
$success false;
      }
    }
    else{
      
$success true;
    }

    return 
$success;
  }
« Last Edit: September 22, 2009, 04:39:56 AM by rosali »
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline hukoeth

  • Newbie
  • *
  • Posts: 2
Failed to connect to remote host when trying to save remote IMAP
« Reply #3 on: September 23, 2009, 02:10:52 AM »
Hi Rosali,
/novalidate-cert works thank you for the quick answer. However it did not fix the problem that I couldn't switch between the accounts (after selecting an account, I was not able to use the dropdown anymore and the account was not switched).
I managed to get this working by changing line 424 from

Code: [Select]
$rcmail->output->add_footer('<div id=&quot;accounts&quot;>
<a href=&quot;' . $link . '&quot; title=&quot;' . $title .'&quot;>' . $selector . '</a></div>');

to

Code: [Select]
$rcmail->output->add_footer('

' . $selector . '
');

So everything is working now :) Thanks for this plug-in and your reply.

Cheers,
Uli

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Failed to connect to remote host when trying to save remote IMAP
« Reply #4 on: September 23, 2009, 05:10:16 AM »
Which browser do you use? Moving the closing tag cause problems in IE6.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)