Close SMTP connection ASAP after the message has been sent

We should not keep the connection open until the script shuts down.
It may take long time e.g. to save the message in IMAP.
pull/5554/head
Aleksander Machniak 9 years ago
parent bd76a921ac
commit 4f5ec65a36

@ -1578,10 +1578,12 @@ class rcube
* @param string $body_file Location of file with saved message body (reference),
* used when delay_file_io is enabled
* @param array $options SMTP options (e.g. DSN request)
* @param bool $disconnect Close SMTP connection ASAP
*
* @return boolean Send status.
*/
public function deliver_message(&$message, $from, $mailto, &$error, &$body_file = null, $options = null)
public function deliver_message(&$message, $from, $mailto, &$error,
&$body_file = null, $options = null, $disconnect = false)
{
$plugin = $this->plugins->exec_hook('message_before_send', array(
'message' => $message,
@ -1681,6 +1683,10 @@ class rcube
fclose($msg_body);
}
if ($disconnect) {
$this->smtp->disconnect();
}
$message->headers($headers, true);
return $sent;

@ -1910,7 +1910,7 @@ function rcmail_send_mdn($message, &$smtp_error)
// SMTP options
$options = array('mdn_use_from' => (bool) $RCMAIL->config->get('mdn_use_from'));
$sent = $RCMAIL->deliver_message($compose, $identity['email'], $mailto, $smtp_error, $body_file, $options);
$sent = $RCMAIL->deliver_message($compose, $identity['email'], $mailto, $smtp_error, $body_file, $options, true);
if ($sent) {
$RCMAIL->storage->set_flag($message->uid, 'MDNSENT');

@ -537,7 +537,7 @@ if (!$savedraft && !$saveonly) {
$smtp_opts['dsn'] = $dsn_enabled;
$sent = $RCMAIL->deliver_message($MAIL_MIME, $from, $mailto,
$smtp_error, $mailbody_file, $smtp_opts);
$smtp_error, $mailbody_file, $smtp_opts, true);
// return to compose page if sending failed
if (!$sent) {

Loading…
Cancel
Save