Skip to content

Commit

Permalink
Markasjunk: Fix marking more than one message as spam/ham with email_…
Browse files Browse the repository at this point in the history
…learn driver (#7121)
  • Loading branch information
alecpl committed Dec 18, 2019
1 parent b25c649 commit 880452f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -5,6 +5,7 @@ CHANGELOG Roundcube Webmail
- Managesieve: Replace "Filter disabled" with "Filter enabled" (#7028)
- Managesieve: Fix so modifier type select wasn't hidden after hiding modifier select on header change
- Managesieve: Fix filter selection after removing a first filter (#7079)
- Markasjunk: Fix marking more than one message as spam/ham with email_learn driver (#7121)
- Password: Fix kpasswd and smb drivers' double-escaping bug (#7092)
- Enigma: Add script to import keys from filesystem to the db storage (for multihost)
- Installer: Fix DB Write test on SQLite database ("database is locked" error) (#7064)
Expand Down
11 changes: 6 additions & 5 deletions plugins/markasjunk/drivers/email_learn.php
Expand Up @@ -45,6 +45,7 @@ private function _do_emaillearn($uids, $spam)
$from = $identity_arr['email'];
$from_string = format_email_recipient($identity_arr['email'], $identity_arr['name']);
$attach = $this->rcube->config->get('markasjunk_email_attach', false);
$debug = $this->rcube->config->get('markasjunk_debug');
$temp_dir = unslashify($this->rcube->config->get('temp_dir'));

$mailto = $this->rcube->config->get($spam ? 'markasjunk_email_spam' : 'markasjunk_email_ham');
Expand All @@ -58,7 +59,7 @@ private function _do_emaillearn($uids, $spam)
$subject = $this->rcube->config->get('markasjunk_email_subject');
$subject = $this->_parse_vars($subject, $spam, $from);

foreach ($uids as $uid) {
foreach ($uids as $i => $uid) {
$MESSAGE = new rcube_message($uid);
$message_file = null;

Expand Down Expand Up @@ -142,19 +143,19 @@ private function _do_emaillearn($uids, $spam)
));
}

$SENDMAIL->deliver_message($MAIL_MIME);
$SENDMAIL->deliver_message($MAIL_MIME, $i == count($uids) - 1);
$message_file = $message_file ?: $MAIL_MIME->mailbody_file;

// clean up
if ($message_file) {
unlink($message_file);
}

if ($this->rcube->config->get('markasjunk_debug')) {
rcube::write_log('', $uid . ($spam ? ' SPAM ' : ' HAM ') . $mailto . ' (' . $subject . ')');
if ($debug) {
rcube::write_log('markasjunk', $uid . ($spam ? ' SPAM ' : ' HAM ') . $mailto . ' (' . $subject . ')');

if ($smtp_error['vars']) {
rcube::write_log('', $smtp_error['vars']);
rcube::write_log('markasjunk', $smtp_error['vars']);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions program/include/rcmail_sendmail.php
Expand Up @@ -362,19 +362,20 @@ public function create_message($headers, $body, $isHtml = false, $attachments =
/**
* Message delivery, and setting Replied/Forwarded flag on success
*
* @param Mail_mime $message Message object
* @param Mail_mime $message Message object
* @param bool $disconnect Close SMTP connection after delivery
*
* @return bool True on success, False on failure
*/
public function deliver_message($message)
public function deliver_message($message, $disconnect = true)
{
// Handle Delivery Status Notification request
$smtp_opts = array('dsn' => $this->options['dsn_enabled']);

$sent = $this->rcmail->deliver_message($message,
$this->options['from'],
$this->options['mailto'],
$smtp_error, $mailbody_file, $smtp_opts, true
$smtp_error, $mailbody_file, $smtp_opts, $disconnect
);

// return to compose page if sending failed
Expand Down

0 comments on commit 880452f

Please sign in to comment.