From ff6734201fb07bca69eb90ffadc310ab279479be Mon Sep 17 00:00:00 2001 From: uckelman Date: Tue, 13 Apr 2010 21:04:54 +0000 Subject: More code. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6704 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/F2M.php | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/F2M.php b/src/F2M.php index 8ed83c2..086a4cd 100644 --- a/src/F2M.php +++ b/src/F2M.php @@ -17,7 +17,8 @@ function send_to_lists($user, $data, $post_data) { $postId = $data['post_id']; $forumId = $data['forum_id']; - + $topidId = $data['topic_id']; + $bridge = new Bridge(); $to = $bridge->getLists($forumId); @@ -44,19 +45,22 @@ function send_to_lists($user, $data, $post_data) { $date = date(DATE_RFC2822, $time); $messageId = build_message_id($time, $postId, $_SERVER['SERVER_NAME']); + $inReplyTo = null; + $references = null; + $forumURL = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']); $body = $data['message']; -/* + print '

'; var_dump($data); var_dump($post_data); print '

'; -*/ - # assemble the message headers +/* + # Assemble the message headers $headers = array( 'To' => $to, 'From' => $from, @@ -66,12 +70,35 @@ function send_to_lists($user, $data, $post_data) { 'X-BeenThere' => $forumURL, ); - # send the message + if ($inReplyTo !== null) { + $headers['In-Reply-To'] = $inReplyTo; + } + + if ($references !== null) { + $headers['References'] = $references; + } + $mailer = Mail::factory('sendmail'); - $err = $mailer->send($to, $headers, $body); - if (PEAR::isError($err)) { - throw new Exception('Mail::send error: ' . $err->toString()); + + $seen = !$bridge->registerMessage($postId, $messageId, + $inReplyTo, $references); + if ($seen) { + throw new Exception('message id already seen: ' . $messageId); } + + try { + # Send the message + $err = $mailer->send($to, $headers, $body); + if (PEAR::isError($err)) { + throw new Exception('Mail::send error: ' . $err->toString()); + } + } + catch (Exception $e) { + # Bridging failed, unregister message. + $bridge->unregisterMessage($messageId); + throw $e; + } +*/ } ?> -- cgit v1.2.3