From 216b31dd99b54e7be3df8feebeafae72e423bb1c Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 25 Feb 2015 05:24:05 -0500 Subject: Fix so "over quota" errors are displayed also in message compose page This also fixes over quota responses on cyrus imap which uses "Over quota" string and no error identifier. --- program/steps/mail/sendmail.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 5843de43f..4f672ac8b 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -635,7 +635,8 @@ if ($store_target) { 'message' => "Could not save message in $store_target"), true, false); if ($savedraft) { - $OUTPUT->show_message('errorsaving', 'error'); + $RCMAIL->display_server_error('errorsaving'); + // start the auto-save timer again $OUTPUT->command('auto_save_start'); $OUTPUT->send('iframe'); @@ -699,7 +700,7 @@ else { $OUTPUT->command('remove_compose_data', $COMPOSE_ID); if ($store_folder && !$saved) { - $OUTPUT->command('sent_successfully', 'error', $RCMAIL->gettext('errorsavingsent'), $folders); + $RCMAIL->display_server_error('errorsavingsent', null, null, array('prefix' => true)); } else if ($store_folder) { $folders[] = $store_target; -- cgit v1.2.3 From c5c8e73351c38ece1b3814a8c82a0439e7424fc4 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 25 Feb 2015 08:07:11 -0500 Subject: Improved handling of storage errors after message is sent After sending a message it is stored in Sent folder, this operation may fail, e.g. because of "over quota" error. In such a case we'll not close the compose window, but display the error and, if user clicks Send/Save button, we'll display a dialog informing about the situation and providing an option to try the save operation again. --- CHANGELOG | 1 + program/js/app.js | 45 +++++++++++++++++++++++++++------ program/localization/en_US/messages.inc | 1 + program/steps/mail/compose.inc | 3 ++- program/steps/mail/sendmail.inc | 39 ++++++++++++++++++---------- 5 files changed, 67 insertions(+), 22 deletions(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/CHANGELOG b/CHANGELOG index 9c6e2b99a..8e31bc914 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ CHANGELOG Roundcube Webmail - Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization) - Add possibility to print contact information (of a single contact) - Add possibility to configure max_allowed_packet value for all database engines (#1490283) +- Improved handling of storage errors after message is sent - Fix refreshing of drafts list when sending a message which was saved in meantime (#1490238) - Fix saving/sending emoticon images when assets_dir is set - Fix PHP fatal error when visiting Vacation interface and there's no sieve script yet diff --git a/program/js/app.js b/program/js/app.js index e818955bd..56d07f37e 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -654,7 +654,7 @@ function rcube_webmail() // check input before leaving compose step if (this.task == 'mail' && this.env.action == 'compose' && $.inArray(command, this.env.compose_commands) < 0 && !this.env.server_error) { - if (this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning'))) + if (!this.env.is_sent && this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning'))) return false; // remove copy from local storage if compose screen is left intentionally @@ -1115,7 +1115,7 @@ function rcube_webmail() break; case 'send': - if (!props.nocheck && !this.check_compose_input(command)) + if (!props.nocheck && !this.env.is_sent && !this.check_compose_input(command)) break; // Reset the auto-save timer @@ -3489,15 +3489,35 @@ function rcube_webmail() .attr({ 'autocomplete': 'off', 'aria-autocomplete': 'list', 'aria-expanded': 'false', 'role': 'combobox' }); }; - this.submit_messageform = function(draft) + this.submit_messageform = function(draft, saveonly) { var form = this.gui_objects.messageform; if (!form) return; + // the message has been sent but not saved, ask the user what to do + if (!saveonly && this.env.is_sent) { + return this.show_popup_dialog(this.get_label('messageissent'), '', + [{ + text: this.get_label('save'), + 'class': 'mainaction', + click: function() { + ref.submit_messageform(false, true); + $(this).dialog('close'); + } + }, + { + text: this.get_label('cancel'), + click: function() { + $(this).dialog('close'); + } + }] + ); + } + // all checks passed, send message - var msgid = this.set_busy(true, draft ? 'savingmessage' : 'sendingmessage'), + var msgid = this.set_busy(true, draft || saveonly ? 'savingmessage' : 'sendingmessage'), lang = this.spellcheck_lang(), files = []; @@ -3511,6 +3531,10 @@ function rcube_webmail() form.action = this.add_url(form.action, '_lang', lang); form.action = this.add_url(form.action, '_framed', 1); + if (saveonly) { + form.action = this.add_url(form.action, '_saveonly', 1); + } + // register timer to notify about connection timeout this.submit_timer = setTimeout(function(){ ref.set_busy(false, null, msgid); @@ -4358,13 +4382,14 @@ function rcube_webmail() }; // action executed after mail is sent - this.sent_successfully = function(type, msg, folders) + this.sent_successfully = function(type, msg, folders, save_error) { this.display_message(msg, type); this.compose_skip_unsavedcheck = true; if (this.env.extwin) { - this.lock_form(this.gui_objects.messageform); + if (!save_error) + this.lock_form(this.gui_objects.messageform); var filter = {task: 'mail', action: ''}, rc = this.opener(false, filter) || this.opener(true, filter); @@ -4377,12 +4402,16 @@ function rcube_webmail() } } - setTimeout(function() { window.close(); }, 1000); + if (!save_error) + setTimeout(function() { window.close(); }, 1000); } - else { + else if (!save_error) { // before redirect we need to wait some time for Chrome (#1486177) setTimeout(function() { ref.list_mailbox(); }, 500); } + + if (save_error) + this.env.is_sent = true; }; diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index e5b368f22..e0de3654e 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -179,5 +179,6 @@ $messages['parentnotwritable'] = 'Unable to create/move folder into selected par $messages['messagetoobig'] = 'The message part is too big to process it.'; $messages['attachmentvalidationerror'] = 'WARNING! This attachment is suspicious because its type doesn\'t match the type declared in the message. If you do not trust the sender, you shouldn\'t open it in the browser because it may contain malicious contents.

Expected: $expected; found: $detected'; $messages['noscriptwarning'] = 'Warning: This webmail service requires Javascript! In order to use it please enable Javascript in your browser\'s settings.'; +$messages['messageissent'] = 'The message was already sent, but not saved yet. Do you want to save it now?'; ?> diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index db4efc7ce..4c3ecfbc0 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -83,7 +83,7 @@ $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubj 'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany', 'fileuploaderror', 'sendmessage', 'newresponse', 'responsename', 'responsetext', 'save', 'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore', - 'selectimportfile'); + 'selectimportfile', 'messageissent'); $OUTPUT->set_pagetitle($RCMAIL->gettext('compose')); @@ -93,6 +93,7 @@ $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder()); $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0); $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ','))); $OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage')); +$OUTPUT->set_env('is_sent', false); $drafts_mbox = $RCMAIL->config->get('drafts_mbox'); $config_show_sig = $RCMAIL->config->get('show_sig', 1); diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 4f672ac8b..e90b0ef61 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -24,7 +24,8 @@ $OUTPUT->reset(); $OUTPUT->framed = TRUE; -$savedraft = !empty($_POST['_draft']) ? true : false; +$saveonly = !empty($_GET['_saveonly']); +$savedraft = !empty($_POST['_draft']) && !$saveonly; $sendmail_delay = (int) $RCMAIL->config->get('sendmail_delay'); $drafts_mbox = $RCMAIL->config->get('drafts_mbox'); @@ -689,24 +690,36 @@ else { // we'll refresh the list if currently opened folder is one of them (#1490238) $folders = array(); - if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) { - $folders[] = $COMPOSE['mailbox']; - } - if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) { - $folders[] = $drafts_mbox; + if (!$saveonly) { + if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) { + $folders[] = $COMPOSE['mailbox']; + } + if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) { + $folders[] = $drafts_mbox; + } } - rcmail_compose_cleanup($COMPOSE_ID); - $OUTPUT->command('remove_compose_data', $COMPOSE_ID); - if ($store_folder && !$saved) { - $RCMAIL->display_server_error('errorsavingsent', null, null, array('prefix' => true)); + $params = $saveonly ? null : array('prefix' => true); + $RCMAIL->display_server_error('errorsavingsent', null, null, $params); + if ($saveonly) { + $OUTPUT->send('iframe'); + } + + $save_error = true; } - else if ($store_folder) { - $folders[] = $store_target; + else { + rcmail_compose_cleanup($COMPOSE_ID); + $OUTPUT->command('remove_compose_data', $COMPOSE_ID); + + if ($store_folder) { + $folders[] = $store_target; + } } - $OUTPUT->command('sent_successfully', 'confirmation', $RCMAIL->gettext('messagesent'), $folders); + $msg = $RCMAIL->gettext($saveonly ? 'successfullysaved' : 'messagesent'); + + $OUTPUT->command('sent_successfully', 'confirmation', $msg, $folders, $save_error); } $OUTPUT->send('iframe'); -- cgit v1.2.3 From 97ee4c40c1e575efb7193fabd32a9d897673f8e2 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 25 Feb 2015 08:23:55 -0500 Subject: Don't sent the message again in saveonly mode --- program/steps/mail/sendmail.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index e90b0ef61..08b085c88 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -517,7 +517,7 @@ if (function_exists('mb_encode_mimeheader')) { $MAIL_MIME->headers($headers); // Begin SMTP Delivery Block -if (!$savedraft) { +if (!$savedraft && !$saveonly) { // check 'From' address (identity may be incomplete) if (empty($from)) { $OUTPUT->show_message('nofromaddress', 'error'); -- cgit v1.2.3 From b59b72cc3028cc0514e951f135d8bfe7efcaaa6f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 26 Feb 2015 18:04:03 +0100 Subject: Fix "Non-static method PEAR::isError() should not be called statically" errors (#1490281) --- CHANGELOG | 1 + plugins/managesieve/lib/Roundcube/rcube_sieve.php | 93 +++++++++++++++------- .../lib/Roundcube/rcube_sieve_engine.php | 5 +- plugins/password/drivers/ldap.php | 6 +- plugins/password/drivers/poppassd.php | 2 +- plugins/password/drivers/vpopmaild.php | 9 ++- program/lib/Roundcube/rcube.php | 15 ++-- program/lib/Roundcube/rcube_smtp.php | 14 ++-- program/steps/mail/sendmail.inc | 7 +- 9 files changed, 99 insertions(+), 53 deletions(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/CHANGELOG b/CHANGELOG index 72ccf7043..4855f2c31 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ CHANGELOG Roundcube Webmail - Fix cursor position on reply below the quote in HTML mode (#1490263) - Fix so "over quota" errors are displayed also in message compose page - Fix duplicate entries supression in autocomplete result (#1490290) +- Fix "Non-static method PEAR::isError() should not be called statically" errors (#1490281) RELEASE 1.1.0 ------------- diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve.php b/plugins/managesieve/lib/Roundcube/rcube_sieve.php index 389c85012..59a7bc134 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve.php @@ -68,7 +68,9 @@ class rcube_sieve $this->sieve->setDebug(true, array($this, 'debug_handler')); } - if (PEAR::isError($this->sieve->connect($host, $port, $options, $usetls))) { + $result = $this->sieve->connect($host, $port, $options, $usetls); + + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_CONNECTION); } @@ -78,9 +80,9 @@ class rcube_sieve $password = $auth_pw; } - if (PEAR::isError($this->sieve->login($username, $password, - $auth_type ? strtoupper($auth_type) : null, $authz)) - ) { + $result = $this->sieve->login($username, $password, $auth_type ? strtoupper($auth_type) : null, $authz); + + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_LOGIN); } @@ -115,22 +117,28 @@ class rcube_sieve */ public function save($name = null) { - if (!$this->sieve) + if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); + } - if (!$this->script) + if (!$this->script) { return $this->_set_error(self::ERROR_INTERNAL); + } - if (!$name) + if (!$name) { $name = $this->current; + } $script = $this->script->as_text(); - if (!$script) + if (!$script) { $script = '/* empty script */'; + } - if (PEAR::isError($this->sieve->installScript($name, $script))) + $result = $this->sieve->installScript($name, $script); + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_INSTALL); + } return true; } @@ -140,14 +148,19 @@ class rcube_sieve */ public function save_script($name, $content = null) { - if (!$this->sieve) + if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); + } - if (!$content) + if (!$content) { $content = '/* empty script */'; + } + + $result = $this->sieve->installScript($name, $content); - if (PEAR::isError($this->sieve->installScript($name, $content))) + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_INSTALL); + } return true; } @@ -157,14 +170,19 @@ class rcube_sieve */ public function activate($name = null) { - if (!$this->sieve) + if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); + } - if (!$name) + if (!$name) { $name = $this->current; + } - if (PEAR::isError($this->sieve->setActive($name))) + $result = $this->sieve->setActive($name); + + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_ACTIVATE); + } return true; } @@ -174,11 +192,15 @@ class rcube_sieve */ public function deactivate() { - if (!$this->sieve) + if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); + } + + $result = $this->sieve->setActive(''); - if (PEAR::isError($this->sieve->setActive(''))) + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DEACTIVATE); + } return true; } @@ -188,22 +210,32 @@ class rcube_sieve */ public function remove($name = null) { - if (!$this->sieve) + if (!$this->sieve) { return $this->_set_error(self::ERROR_INTERNAL); + } - if (!$name) + if (!$name) { $name = $this->current; + } // script must be deactivated first - if ($name == $this->sieve->getActive()) - if (PEAR::isError($this->sieve->setActive(''))) + if ($name == $this->sieve->getActive()) { + $result = $this->sieve->setActive(''); + + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DELETE); + } + } + + $result = $this->sieve->removeScript($name); - if (PEAR::isError($this->sieve->removeScript($name))) + if (is_a($result, 'PEAR_Error')) { return $this->_set_error(self::ERROR_DELETE); + } - if ($name == $this->current) + if ($name == $this->current) { $this->current = null; + } return true; } @@ -221,7 +253,7 @@ class rcube_sieve $ext = $this->sieve->getExtensions(); - if (PEAR::isError($ext)) { + if (is_a($ext, 'PEAR_Error')) { return array(); } @@ -250,8 +282,9 @@ class rcube_sieve $list = $this->sieve->listScripts(); - if (PEAR::isError($list)) + if (is_a($list, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); + } $this->list = $list; } @@ -283,8 +316,9 @@ class rcube_sieve $script = $this->sieve->getScript($name); - if (PEAR::isError($script)) + if (is_a($script, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); + } // try to parse from Roundcube format $this->script = $this->_parse($script); @@ -349,8 +383,9 @@ class rcube_sieve $content = $this->sieve->getScript($name); - if (PEAR::isError($content)) + if (is_a($content, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); + } return $content; } @@ -366,10 +401,12 @@ class rcube_sieve if ($copy) { $content = $this->sieve->getScript($copy); - if (PEAR::isError($content)) + if (is_a($content, 'PEAR_Error')) { return $this->_set_error(self::ERROR_OTHER); + } } + return $this->save_script($name, $content); } diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 69ae4b8a6..98c4c952c 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -390,10 +390,11 @@ class rcube_sieve_engine } else if ($action == 'setget') { $script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true); - $script = $this->sieve->get_script($script_name); + $script = $this->sieve->get_script($script_name); - if (PEAR::isError($script)) + if (is_a($script, 'PEAR_Error')) { exit; + } $browser = new rcube_browser; diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index c18ff0f06..a11c38d17 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -75,7 +75,7 @@ class rcube_ldap_password $ldap = Net_LDAP2::connect($ldapConfig); // Checking for connection error - if (PEAR::isError($ldap)) { + if (is_a($ldap, 'PEAR_Error')) { return PASSWORD_CONNECT_ERROR; } @@ -176,7 +176,7 @@ class rcube_ldap_password $ldap = Net_LDAP2::connect($ldapConfig); - if (PEAR::isError($ldap)) { + if (is_a($ldap, 'PEAR_Error')) { return ''; } @@ -189,7 +189,7 @@ class rcube_ldap_password $result = $ldap->search($base, $filter, $options); $ldap->done(); - if (PEAR::isError($result) || ($result->count() != 1)) { + if (is_a($result, 'PEAR_Error') || ($result->count() != 1)) { return ''; } diff --git a/plugins/password/drivers/poppassd.php b/plugins/password/drivers/poppassd.php index 8ddbef5d3..7a2821083 100644 --- a/plugins/password/drivers/poppassd.php +++ b/plugins/password/drivers/poppassd.php @@ -42,7 +42,7 @@ class rcube_poppassd_password $poppassd = new Net_Socket(); $result = $poppassd->connect($rcmail->config->get('password_pop_host'), $rcmail->config->get('password_pop_port'), null); - if (PEAR::isError($result)) { + if (is_a($result, 'PEAR_Error')) { return $this->format_error_result(PASSWORD_CONNECT_ERROR, $result->getMessage()); } else { diff --git a/plugins/password/drivers/vpopmaild.php b/plugins/password/drivers/vpopmaild.php index a7644fc21..90fce02c5 100644 --- a/plugins/password/drivers/vpopmaild.php +++ b/plugins/password/drivers/vpopmaild.php @@ -28,12 +28,13 @@ class rcube_vpopmaild_password { function save($curpass, $passwd) { - $rcmail = rcmail::get_instance(); - // include('Net/Socket.php'); + $rcmail = rcmail::get_instance(); $vpopmaild = new Net_Socket(); + $host = $rcmail->config->get('password_vpopmaild_host'); + $port = $rcmail->config->get('password_vpopmaild_port'); - if (PEAR::isError($vpopmaild->connect($rcmail->config->get('password_vpopmaild_host'), - $rcmail->config->get('password_vpopmaild_port'), null))) { + $result = $vpopmaild->connect($hostname, $port, null); + if (is_a($result, 'PEAR_Error')) { return PASSWORD_CONNECT_ERROR; } diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 3aca88843..20f509e3d 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1681,15 +1681,18 @@ class rcube if ($message->getParam('delay_file_io')) { // use common temp dir - $temp_dir = $this->config->get('temp_dir'); - $body_file = tempnam($temp_dir, 'rcmMsg'); - if (PEAR::isError($mime_result = $message->saveMessageBody($body_file))) { + $temp_dir = $this->config->get('temp_dir'); + $body_file = tempnam($temp_dir, 'rcmMsg'); + $mime_result = $message->saveMessageBody($body_file); + + if (is_a($mime_result, 'PEAR_Error')) { self::raise_error(array('code' => 650, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not create message: ".$mime_result->getMessage()), - TRUE, FALSE); + true, false); return false; } + $msg_body = fopen($body_file, 'r'); } else { @@ -1732,11 +1735,11 @@ class rcube $msg_body = $message->get(); - if (PEAR::isError($msg_body)) { + if (is_a($msg_body, 'PEAR_Error')) { self::raise_error(array('code' => 650, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not create message: ".$msg_body->getMessage()), - TRUE, FALSE); + true, false); } else { $delim = $this->config->header_delimiter(); diff --git a/program/lib/Roundcube/rcube_smtp.php b/program/lib/Roundcube/rcube_smtp.php index b37b44426..0322a0d46 100644 --- a/program/lib/Roundcube/rcube_smtp.php +++ b/program/lib/Roundcube/rcube_smtp.php @@ -126,7 +126,7 @@ class rcube_smtp // try to connect to server and exit on failure $result = $this->conn->connect($CONFIG['smtp_timeout']); - if (PEAR::isError($result)) { + if (is_a($result, 'PEAR_Error')) { $this->response[] = "Connection failed: ".$result->getMessage(); $this->error = array('label' => 'smtpconnerror', 'vars' => array('code' => $this->conn->_code)); $this->conn = null; @@ -159,7 +159,7 @@ class rcube_smtp $result = $this->conn->auth($smtp_user, $smtp_pass, $smtp_auth_type, $use_tls, $smtp_authz); - if (PEAR::isError($result)) { + if (is_a($result, 'PEAR_Error')) { $this->error = array('label' => 'smtpautherror', 'vars' => array('code' => $this->conn->_code)); $this->response[] .= 'Authentication failure: ' . $result->getMessage() . ' (Code: ' . $result->getCode() . ')'; $this->reset(); @@ -240,7 +240,8 @@ class rcube_smtp } // set From: address - if (PEAR::isError($this->conn->mailFrom($from, $from_params))) { + $result = $this->conn->mailFrom($from, $from_params); + if (is_a($result, 'PEAR_Error')) { $err = $this->conn->getResponse(); $this->error = array('label' => 'smtpfromerror', 'vars' => array( 'from' => $from, 'code' => $err[0], 'msg' => $err[1])); @@ -252,7 +253,7 @@ class rcube_smtp // prepare list of recipients $recipients = $this->_parse_rfc822($recipients); - if (PEAR::isError($recipients)) { + if (is_a($recipients, 'PEAR_Error')) { $this->error = array('label' => 'smtprecipientserror'); $this->reset(); return false; @@ -260,7 +261,8 @@ class rcube_smtp // set mail recipients foreach ($recipients as $recipient) { - if (PEAR::isError($this->conn->rcptTo($recipient, $recipient_params))) { + $result = $this->conn->rcptTo($recipient, $recipient_params); + if (is_a($result, 'PEAR_Error')) { $err = $this->conn->getResponse(); $this->error = array('label' => 'smtptoerror', 'vars' => array( 'to' => $recipient, 'code' => $err[0], 'msg' => $err[1])); @@ -289,7 +291,7 @@ class rcube_smtp // Send the message's headers and the body as SMTP data. $result = $this->conn->data($data, $text_headers); - if (PEAR::isError($result)) { + if (is_a($result, 'PEAR_Error')) { $err = $this->conn->getResponse(); if (!in_array($err[0], array(354, 250, 221))) { $msg = sprintf('[%d] %s', $err[0], $err[1]); diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 08b085c88..9e674f773 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -601,8 +601,9 @@ if ($store_target) { else { $temp_dir = $RCMAIL->config->get('temp_dir'); $mailbody_file = tempnam($temp_dir, 'rcmMsg'); + $msg = $MAIL_MIME->saveMessageBody($mailbody_file); - if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) { + if (!is_a($msg, 'PEAR_Error')) { $msg = $mailbody_file; } } @@ -612,7 +613,7 @@ if ($store_target) { $headers = ''; } - if (PEAR::isError($msg)) { + if (is_a($msg, 'PEAR_Error')) { rcube::raise_error(array('code' => 650, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not create message: ".$msg->getMessage()), @@ -800,7 +801,7 @@ function rcmail_fix_emoticon_paths($mime_message) if (!in_array($image_name, $included_images)) { // add the image to the MIME message $res = $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name); - if (PEAR::isError($res)) { + if (is_a($res, 'PEAR_Error')) { $RCMAIL->output->show_message("emoticonerror", 'error'); continue; } -- cgit v1.2.3 From f02fe3c3444a5ed7736ea532071269bb8f488fb8 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 4 Mar 2015 12:28:33 -0500 Subject: Remove redundant encoding of message subject with mb_encode_mimeheader() (#1490295) --- program/steps/mail/sendmail.inc | 8 -------- 1 file changed, 8 deletions(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 9e674f773..5326d6452 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -505,14 +505,6 @@ $MAIL_MIME->setParam('head_charset', $message_charset); $MAIL_MIME->setParam('html_charset', $message_charset); $MAIL_MIME->setParam('text_charset', $text_charset); -// encoding subject header with mb_encode provides better results with asian characters -if (function_exists('mb_encode_mimeheader')) { - mb_internal_encoding($message_charset); - $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], - $message_charset, 'Q', "\r\n", 8); - mb_internal_encoding(RCUBE_CHARSET); -} - // pass headers to message object $MAIL_MIME->headers($headers); -- cgit v1.2.3 From 0a4e0921d3c4e4e1e485f43dc05bf0447fbc846a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 31 Mar 2015 16:07:51 +0200 Subject: Plugin API: Added message_ready hook - the last chance to modify Mail_Mime object before saving or sending the message --- CHANGELOG | 1 + program/steps/mail/sendmail.inc | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'program/steps/mail/sendmail.inc') diff --git a/CHANGELOG b/CHANGELOG index d14566ddf..41cd629de 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ CHANGELOG Roundcube Webmail - Password plugin: Added 'kpasswd' driver by Peter Allgeyer - Add initdb.sh to create database from initial.sql script with prefix support (#1490188) - Plugin API: Added message_part_body hook +- Plugin API: Added message_ready hook - Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization) - Fix handling of %-encoded entities in mailto: URLs (#1490346) - Fix zipped messages downloads after selecting all messages in a folder (#1490339) diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 5326d6452..b3034f57d 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -113,6 +113,12 @@ else if ($from_string = rcmail_email_input_format($from)) { $from = null; } +// check 'From' address (identity may be incomplete) +if (!$savedraft && !$saveonly && empty($from)) { + $OUTPUT->show_message('nofromaddress', 'error'); + $OUTPUT->send('iframe'); +} + if (!$from_string && $from) { $from_string = $from; } @@ -508,14 +514,12 @@ $MAIL_MIME->setParam('text_charset', $text_charset); // pass headers to message object $MAIL_MIME->headers($headers); +// This hook allows to modify the message before send or save action +$plugin = $RCMAIL->plugins->exec_hook('message_ready', array('message' => $MAIL_MIME)); +$MAIL_MIME = $plugin['message']; + // Begin SMTP Delivery Block if (!$savedraft && !$saveonly) { - // check 'From' address (identity may be incomplete) - if (empty($from)) { - $OUTPUT->show_message('nofromaddress', 'error'); - $OUTPUT->send('iframe'); - } - // Handle Delivery Status Notification request $smtp_opts['dsn'] = $dsn_enabled; -- cgit v1.2.3