*/
class Deliver {
+ /**
+ * Most recently calculated Message-ID
+ * External code should NEVER access this directly!
+ * @var string
+ */
+ var $message_id;
+
/**
* function mail - send the message parts to the SMTP stream
*
* an overloaded version of this method
* if needed.
*
- * @return integer $raw_length The number of bytes written (or that would
- * have been written) to the output stream
+ * @return array An array containing at least these elements in this order:
+ * - The number of bytes written (or that would have been
+ * written) to the output stream
+ * - The message ID (WARNING: if $stream is FALSE, this
+ * may not be supplied, or may not be accurate)
+ *
*/
function mail($message, $stream=false, $reply_id=0, $reply_ent_id=0,
$extra=NULL) {
$this->send_mail($message, $header, $boundary, $stream, $raw_length, $extra);
- return $raw_length;
+ return array($raw_length, $this->message_id);
}
/**
$message_id.= $REMOTE_ADDR;
}
$message_id .= '.' . time() . '.squirrel@' . $SERVER_NAME .'>';
+ $this->message_id = $message_id;
+
/* Make an RFC822 Received: line */
if (isset($REMOTE_HOST)) {
$received_from = "$REMOTE_HOST ([$REMOTE_ADDR])";
* In the future the responsible backend should be automaticly loaded
* and conf.pl should show a list of available backends.
* The message also should be constructed by the message class.
+ *
+ * @return boolean FALSE if delivery failed, or some non-FALSE value
+ * upon success.
+ *
*/
function deliverMessage($composeMessage, $draft=false) {
global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body,
- $username, $identity, $idents, $data_dir,
+ $username, $identity, $idents, $data_dir, $message_id,
$request_mdn, $request_dr, $default_charset, $useSendmail,
$domain, $action, $default_move_to_sent, $move_to_sent,
$imapServerAddress, $imapPort, $sent_folder, $key;
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
$imap_deliver = new Deliver_IMAP();
- $length = $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $draft_folder);
+ list($success, $ignore) = $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $draft_folder);
sqimap_logout($imap_stream);
unset ($imap_deliver);
$composeMessage->purgeAttachments();
- return $length;
+ return $success;
} else {
$msg = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder));
plain_error_message($msg);
}
$success = false;
if ($stream) {
- $length = $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id);
+ list($ignore, $message_id) = $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id);
$success = $deliver->finalizeStream($stream);
}
if (!$success) {