Author Topic: Cannot connect to managesieve  (Read 575 times)

Offline Abatjour3407

  • Newbie
  • *
  • Posts: 6
Cannot connect to managesieve
« on: April 21, 2020, 03:27:20 PM »
Hi

I've had this problem for over a year now and never got around to fixing it. I'm running RoundCube 1.4 and whenever I try to add a filter under settings (or even if I click on the filters tab) I get the error message "cannot connect to managesieve". I've scoured Google looking for a solution on numerous occasions, my web host support team don't know the answer and my web developer has been trying to figure this out for a month already... Any help would be greatly appreciated!! If there's any info I can provide that may be useful please ask in the comments. Thanks!
« Last Edit: April 24, 2020, 01:24:05 AM by Abatjour3407 »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,438
Re: Cannot connect to managesieve
« Reply #1 on: April 22, 2020, 04:14:11 AM »
Check the config file if the plugin you are using to ensure you have put the correct server information in it. Also may be have a look in the roundcube error log, that may have some more details of why it couldnt connect.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline Abatjour3407

  • Newbie
  • *
  • Posts: 6
Re: Cannot connect to managesieve
« Reply #2 on: April 23, 2020, 03:51:16 AM »
Thanks so much JohnDoh! Such fundamental guidance that I feel has really helped to get closer to the root of the problem. This is what I have found:

Is the problem with the null values and/or the false value (the domain is an https domain - uses a wildcard DV SSL) in the managesieve config file? If so what should these values be/ where would I find them/ where am I already using them?

MANAGESIEVE CONFIG VALUES:
Port: 4190
host: 'localhost'
auth_type: null
auth_cid: null
auth_pw: null
usetls: false
conn_options: null

ERROR MESSAGES IN LOG FILE
<d5104e1a> PHP Error: Unable to connect to managesieve on localhost:4190 in /home/legacy88/msg.legacy.live/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php on line 222 (GET /?_task=settings&_action=plugin.managesieve)

<d5104e1a> PHP Error: Not currently in AUTHORISATION state (GET /?_task=settings&_action=plugin.managesieve)

<d5104e1a> PHP Error: Connection refused (GET /?_task=settings&_action=plugin.managesieve)



THIS IS WHERE THE ERROR IS GENERATED:

public function connect($username, $password) {
// Get connection parameters
$host = $this->rc->config->get('managesieve_host', 'localhost');
$port = $this->rc->config->get('managesieve_port');
$tls = $this->rc->config->get('managesieve_usetls', false);
$host = rcube_utils::parse_host($host); $host = rcube_utils::idn_to_ascii($host);

// remove tls:// prefix, set TLS flag
if (($host = preg_replace('|^tls://|i', '', $host, 1, $cnt)) && $cnt) {
$tls = true;
}

if (empty($port)) {
$port = getservbyname('sieve', 'tcp') ?: self::PORT;
}

$plugin = $this->rc->plugins->exec_hook('managesieve_connect', array(
 'user' => $username,
'password' => $password,
'host' => $host,
'port' => $port,
'usetls' => $tls,
'auth_type' => $this->rc->config->get('managesieve_auth_type'),
'disabled' => $this->rc->config->get('managesieve_disabled_extensions'),
'debug' => $this->rc->config->get('managesieve_debug', false),
'auth_cid' => $this->rc->config->get('managesieve_auth_cid'),
'auth_pw' => $this->rc->config->get('managesieve_auth_pw'),
'socket_options' => $this->rc->config->get('managesieve_conn_options') ));

// Handle per-host socket options rcube_utils::parse_socket_options($plugin['socket_options'], $plugin['host']);

// try to connect to managesieve server and to fetch the script
$this->sieve = new rcube_sieve(
$plugin['user'],
$plugin['password'],
$plugin['host'],
$plugin['port'],
$plugin['auth_type'],
$plugin['usetls'],
$plugin['disabled'],
$plugin['debug'],
$plugin['auth_cid'],
$plugin['auth_pw'],
$plugin['socket_options'],
$plugin['gssapi_context'],
$plugin['gssapi_cn']
);
$error =
$this->sieve->error();

if ($error) {
rcube::raise_error(array(
'code' => 403,
'file' => __FILE__,
'line' => __LINE__,
'message' => "Unable to connect to managesieve on $host:$port"
), true, false);
}




Thanks again for your assistance!

Offline Abatjour3407

  • Newbie
  • *
  • Posts: 6
Re: Cannot connect to managesieve
« Reply #3 on: April 23, 2020, 03:56:43 AM »
Oh and here's where the function connect is being called:

$error = $this->connect($_SESSION['username'], $this->rc->decrypt($_SESSION['password']));
       

Offline alec

  • Hero Member
  • *****
  • Posts: 1,187
Re: Cannot connect to managesieve
« Reply #4 on: April 23, 2020, 04:20:23 AM »
Why are you digging into the code if your problem is with configuration? What are your imap_* settings? Is managesieve service running at all?

Offline Abatjour3407

  • Newbie
  • *
  • Posts: 6
Re: Cannot connect to managesieve
« Reply #5 on: April 23, 2020, 10:03:22 AM »
Thanks for your fast reply Alec! Good question about the code. I am very new even the most basics of networking and integration (for now), so trying to follow the path of logic behind an error message helps me to understand what is happening a little bit better.

These are my IMAP settings I use to setup email accounts on devices:
Incoming server: legacy.live
IMAP Port: 993
Username and Password unique for each user

There are also these references to IMAP in managesieve/config.inc.php:
// The IMAP host chosen to perform the log-in.
$config['default_host'] = 'localhost';

AND

// Optional managesieve authentication password to be used for imap_auth_cid
$config['managesieve_auth_pw'] = null;

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,438
Re: Cannot connect to managesieve
« Reply #6 on: April 23, 2020, 02:18:19 PM »
To use the managesieve plugin that ships with Roundcube you need to have a managesieve server to connect to. For example Dovecot supports sieve and you can run a managesieve server, see this https://doc.dovecot.org/admin_manual/pigeonhole_managesieve_server/.

The purpose of the plugin is to manage sieve filter rules on your MUA so it has to have a server to interact with.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline Abatjour3407

  • Newbie
  • *
  • Posts: 6
Re: Cannot connect to managesieve
« Reply #7 on: April 24, 2020, 09:19:56 PM »
Hi John Doh

Thanks again for your quick reply and for the useful info.

So if I understand correctly there are 4 parts to getting filters to work on RoundCube:
1) An MUA (had to look this up) which in my case is RoundCube
2) The RoundCube plugin (managesieve) — which I definitely have and I'm not sure it's set up correctly
3) A server (which I also have and I receive and send emails using it perfectly well)
4) I need something to make my server a managesieve server... This part I don't fully understand but you recommend Dovecot. I don't know if I have this and then I need Pigeonhole on top of this? The document explains (in a very technical way) how to install this but does it matter where I upload this for installation?

Thanks so much for taking the time to answer this for me. I think I'm beginning to understand this a little better. My experience and knowledge is likely much less developed in this area than most on this forum but a more easy to grasp explanation might also help the odd visitor coming here with the same experience.

Thanks again!

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,438
Re: Cannot connect to managesieve
« Reply #8 on: April 25, 2020, 02:33:56 AM »
When I put MUA. That was a typo. Roundcube is your MUA in this case. I meant to say MDA. That's the Mail Delivery Agent typically your IMAP server eg Dovecot. What IMAP server are you running?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline Abatjour3407

  • Newbie
  • *
  • Posts: 6
Re: Cannot connect to managesieve
« Reply #9 on: April 25, 2020, 09:30:49 AM »
My MDA is dovecot...