summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/func.inc14
-rw-r--r--program/steps/mail/show.inc30
2 files changed, 33 insertions, 11 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 95bae0b10..d7c65236b 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1584,12 +1584,20 @@ function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_
return $sent;
}
-
-function rcmail_send_mdn($uid, &$smtp_error)
+/**
+ * Send the MDN response
+ *
+ * @param mixed $message Original message object (rcube_message) or UID
+ * @param array $smtp_error SMTP error array (reference)
+ *
+ * @return boolean Send status
+ */
+function rcmail_send_mdn($message, &$smtp_error)
{
global $RCMAIL, $IMAP;
- $message = new rcube_message($uid);
+ if (!is_a($message, rcube_message))
+ $message = new rcube_message($message);
if ($message->headers->mdn_to && !$message->headers->mdn_sent &&
($IMAP->check_permflag('MDNSENT') || $IMAP->check_permflag('*')))
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 382733f5e..bc208ab7c 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -72,17 +72,19 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
$mbox_name != $CONFIG['drafts_mbox'] &&
$mbox_name != $CONFIG['sent_mbox'])
{
- if (intval($CONFIG['mdn_requests']) === 1)
- {
- if (rcmail_send_mdn($MESSAGE->uid, $smtp_error))
+ $mdn_cfg = intval($CONFIG['mdn_requests']);
+
+ if ($mdn_cfg == 1 || ($mdn_cfg == 3 && rcmail_contact_exists($MESSAGE->sender['mailto']))) {
+ // Send MDN
+ if (rcmail_send_mdn($MESSAGE, $smtp_error))
$OUTPUT->show_message('receiptsent', 'confirmation');
else if ($smtp_error)
$OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']);
else
$OUTPUT->show_message('errorsendingreceipt', 'error');
}
- else if (empty($CONFIG['mdn_requests']))
- {
+ else if ($mdn_cfg != 2) {
+ // Ask user
$OUTPUT->add_label('mdnrequest');
$OUTPUT->set_env('mdn_request', true);
}
@@ -181,8 +183,6 @@ function rcmail_message_attachments($attrib)
return $out;
}
-
-
function rcmail_remote_objects_msg($attrib)
{
global $MESSAGE, $RCMAIL;
@@ -203,6 +203,21 @@ function rcmail_remote_objects_msg($attrib)
return html::div($attrib, $msg);
}
+function rcmail_contact_exists($email)
+{
+ global $RCMAIL;
+
+ if ($email) {
+ // @TODO: search in all address books?
+ $CONTACTS = $RCMAIL->get_address_book(null, true);
+ $existing = $CONTACTS->search('email', $email, true, false);
+ if ($existing->count)
+ return true;
+ }
+
+ return false;
+}
+
$OUTPUT->add_handlers(array(
'messageattachments' => 'rcmail_message_attachments',
@@ -228,4 +243,3 @@ if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen &&
exit;
-