From ad5cfb788fd4a9266c666cdb14fc5d10a0f77947 Mon Sep 17 00:00:00 2001 From: uckelman Date: Tue, 13 Apr 2010 19:58:06 +0000 Subject: Added mail code. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6698 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/F2M.php | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/F2M.php b/src/F2M.php index e4cd479..df988d3 100644 --- a/src/F2M.php +++ b/src/F2M.php @@ -9,18 +9,23 @@ catch (Exception $e) { function send_to_lists($user, $data, $post_data) { - require_once(__DIR__ . '/PhpBB3.php'); - require_once(__DIR__ . '/Util.php'); - - $phpbb = new PhpBB3(); - -/* require_once('Mail.php'); require_once(__DIR__ . '/Bridge.php'); -*/ + require_once(__DIR__ . '/PhpBB3.php'); + require_once(__DIR__ . '/Util.php'); $postId = $data['post_id']; + $forumId = $data['forum_id']; + + $bridge = new Bridge(); + + $to = $bridge->getLists($forumId); + if (count($to) == 0) { + # No lists to send to, bail out. + return; + } + $to = implode(', ', $to); $userName = $user->data['username']; $userEmail = $user->data['user_email']; @@ -29,6 +34,8 @@ function send_to_lists($user, $data, $post_data) { $sender = 'forum@test.nomic.net'; $subject = utf8_quote($post_data['post_subject']); + $phpbb = new PhpBB3(); + $time = $phpbb->getPostTime($postId); if ($time === false) { throw new Exception('no post time: ' . $postId); @@ -42,30 +49,29 @@ function send_to_lists($user, $data, $post_data) { $body = $data['message']; +/* print '

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

'; +*/ -/* - $bridge = new Bridge(); - - $to = $bridge->getLists($forumId); - if ($to == false) { - + # assemble the message headers $headers = array( - 'To' => implode(', ', $to), - 'From' => "$userName <$userEmail>", + 'To' => $to, + 'From' => $from, 'Subject' => $subject, 'Date', => $date, 'Message-Id', => $messageId, 'X-BeenThere' => $forumURL, ); + # send the message $mailer = Mail::factory('sendmail'); - $mailer->send($to, $headers, $body); -*/ - + $err = $mailer->send($to, $headers, $body); + if (PEAR::isError($err)) { + throw new Exception('Mail::send error: ' . $err->toString()); + } } ?> -- cgit v1.2.3