From ae7b905824ba762273597c3ab7b03eb2085963fd Mon Sep 17 00:00:00 2001 From: Mickael Date: Sat, 15 Jan 2022 21:48:55 +0000 Subject: [PATCH 1/2] ident_switch.php - Solve the issue that don't set the good configuration variable for the smtp_host on the latest version + dev of roundcube --- ident_switch.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ident_switch.php b/ident_switch.php index 7d7ed4f..31e7321 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -179,15 +179,15 @@ class ident_switch extends rcube_plugin $args['smtp_user'] = $r['username']; $args['smtp_pass'] = $r['smtp_auth'] == self::SMTP_AUTH_IMAP ? $rc->decrypt($r['password']) : ''; - $args['smtp_server'] = $r['smtp_host'] ? $r['smtp_host'] : 'localhost'; // Default SMTP host here + $args['smtp_host'] = $r['smtp_host'] ? $r['smtp_host'] : 'localhost'; // Default SMTP host here $args['smtp_port'] = $r['smtp_port'] ? $r['smtp_port'] : 587; // Default SMTP port here if ($r['flags'] & self::DB_SECURE_IMAP_TLS) { - if (strpos($args['smtp_server'], ':') !== false) + if (strpos($args['smtp_host'], ':') !== false) self::write_log('SMTP server already contains protocol, ignoring TLS flag.'); else - $args['smtp_server'] = 'tls://' . $args['smtp_server']; + $args['smtp_host'] = 'tls://' . $args['smtp_host']; } } From ad97f4bfd00511fe109cc61628178260c8b2e69b Mon Sep 17 00:00:00 2001 From: Boris Gulay Date: Mon, 17 Jan 2022 19:30:39 +0300 Subject: [PATCH 2/2] Use identity from field. Thanx Daniel Haag. Closes #44. --- composer.json | 2 +- ident_switch.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 579784a..dbee182 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "authors": [ { "name": "Boris Gulay", - "email": "boris@boressoft.ru", + "email": "boris@gulay.name", "role": "Developer" } ], diff --git a/ident_switch.php b/ident_switch.php index 31e7321..c7fa91d 100644 --- a/ident_switch.php +++ b/ident_switch.php @@ -159,7 +159,20 @@ class ident_switch extends rcube_plugin { $iid = $_SESSION['iid' . self::MY_POSTFIX]; if (!is_numeric($iid) || $iid == -1) - return $args; + { + self::write_log('no identity switch is selected... trying to find related smtp server from the from header'); + $requestFrom = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST); + if (empty($requestFrom)) { + self::write_log('no _from post parameter found... falling back to original default config'); + return $args; + } else { + $iid = intval($requestFrom); + if ($iid == 0) { + self::write_log('falling back to original default config as _from post field is no integer: ' . $_POST['_from']); + return $args; + } + } + } $rc = rcmail::get_instance();