diff --git a/og_mailinglist_api.inc b/og_mailinglist_api.inc
index d2deb30..ff40c61 100644
--- a/og_mailinglist_api.inc
+++ b/og_mailinglist_api.inc
@@ -188,7 +188,9 @@ function og_mailinglist_log_email_sent($source, $nid, $cid = 0, $message_id = 0,
  */
 function og_mailinglist_create_mailer() {
   og_mailinglist_phpmailer_load_library();
-  $mailer = new PHPMailer(TRUE); // The TRUE param means it will throw exceptions on errors, which we need to catch.
+  module_load_include('inc', 'og_mailinglist', 'og_mailinglist_phpmailer_class');
+  $mailer = new OGMailinglistPHPMailer(TRUE); // The TRUE param means it will throw exceptions on errors, which we need to catch.
+  $mailer->PluginDir = og_mailinglist_get_phpmailer_plugin_dir();
   $mailer->CharSet = 'UTF-8';
 
   return $mailer;
diff --git a/og_mailinglist_phpmailer_class.inc b/og_mailinglist_phpmailer_class.inc
new file mode 100644
index 0000000..a3e0f7e
--- /dev/null
+++ b/og_mailinglist_phpmailer_class.inc
@@ -0,0 +1,165 @@
+<?php
+// $Id: phpmailer.class.inc,v 1.17.2.5 2010/07/07 12:41:38 smk Exp $
+
+/**
+ * @file
+ * Implements the base PHPMailer for OGMailinglist class.
+ */
+
+/**
+ * Base PHPMailer for Drupal implementation with support for SMTP keep-alive
+ * and setting a custom Return-Path.
+ */
+class OGMailinglistPHPMailer extends PHPMailer {
+  /**
+   * Stores the addresses we want to deliver the message to.
+   */
+  private   $DeliverTo = array();
+
+  /**
+   * Stores the incoming message's date.
+   */
+  public $MessageDate = '';
+
+  /**
+   * Public wrapper around PHPMailer::RFCDate().
+   */
+  public function RFCDate() {
+    return $this->MessageDate;
+  }
+
+  public function AddDeliverTo($address) {
+    $this->DeliverTo[] = $address;
+  }
+
+  /**
+   * Sends mail using the $Sendmail program.
+   * @param string $header The message headers
+   * @param string $body The message body
+   * @access protected
+   * @return bool
+   */
+  public function SendmailSendDeliverTo($header, $body) {
+    if ($this->Sender != '') {
+      $sendmail = sprintf("%s -oi -f %s %s", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender),
+        escapeshellarg(implode(', ', $this->DeliverTo)));
+    } else {
+      $sendmail = sprintf("%s -oi %s", escapeshellcmd($this->Sendmail), escapeshellarg($this->DeliverTo));
+    }
+    if(!@$mail = popen($sendmail, 'w')) {
+      throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
+    }
+    fputs($mail, $header);
+    fputs($mail, $body);
+    $result = pclose($mail);
+    // implement call back function if it exists
+    $isSent = ($result == 0) ? 1 : 0;
+    $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
+    if($result != 0) {
+      throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
+    }
+    return true;
+  }
+
+  /**
+   * Sends mail via SMTP using PhpSMTP
+   * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
+   * @param string $header The message headers
+   * @param string $body The message body
+   * @uses SMTP
+   * @access protected
+   * @return bool
+   */
+  protected function SmtpSendDeliverTo($header, $body) {
+    require_once $this->PluginDir . 'class.smtp.php';
+    $bad_rcpt = array();
+
+    if(!$this->SmtpConnect()) {
+      throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
+    }
+    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
+    if(!$this->smtp->Mail($smtp_from)) {
+      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
+    }
+
+    // Attempt to send attach all recipients
+    foreach($this->DeliverTo as $to) {
+      if (!$this->smtp->Recipient($to)) {
+        $bad_rcpt[] = $to[0];
+        // implement call back function if it exists
+        $isSent = 0;
+        $this->doCallback($isSent,$to,'','',$this->Subject,$body);
+      } else {
+        // implement call back function if it exists
+        $isSent = 1;
+        $this->doCallback($isSent,$to,'','',$this->Subject,$body);
+      }
+    }
+
+    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
+      $badaddresses = implode(', ', $bad_rcpt);
+      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
+    }
+    if(!$this->smtp->Data($header . $body)) {
+      throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
+    }
+    if($this->SMTPKeepAlive == true) {
+      $this->smtp->Reset();
+    }
+    return true;
+  }
+
+  /**
+   * Creates message and assigns Mailer. If the message is
+   * not sent successfully then it returns false.  Use the ErrorInfo
+   * variable to view description of the error.
+   * @return bool
+   */
+  public function Send() {
+    if (count($this->DeliverTo) < 1) {
+      return parent::Send();
+    }
+
+    try {
+      // Set whether the message is multipart/alternative
+      if(!empty($this->AltBody)) {
+        $this->ContentType = 'multipart/alternative';
+      }
+
+      $this->error_count = 0; // reset errors
+      $this->SetMessageType();
+      $header = $this->CreateHeader();
+      $body = $this->CreateBody();
+
+      if (empty($this->Body)) {
+        throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
+      }
+
+      // digitally sign with DKIM if enabled
+      if ($this->DKIM_domain && $this->DKIM_private) {
+        $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
+        $header = str_replace("\r\n","\n",$header_dkim) . $header;
+      }
+
+      // Choose the mailer and send through it
+      switch($this->Mailer) {
+        case 'sendmail':
+          return $this->SendmailSendDeliverTo($header, $body);
+        case 'smtp':
+          return $this->SmtpSendDeliverTo($header, $body);
+        default:
+          return $this->MailSend($header, $body);
+      }
+
+    } catch (phpmailerException $e) {
+      $this->SetError($e->getMessage());
+      if ($this->exceptions) {
+        throw $e;
+      }
+      echo $e->getMessage()."\n";
+      return false;
+    }
+  }
+
+}
+
diff --git a/og_mailinglist_transport.inc b/og_mailinglist_transport.inc
index 3470ded..94734f0 100755
--- a/og_mailinglist_transport.inc
+++ b/og_mailinglist_transport.inc
@@ -351,10 +351,12 @@ function _og_mailinglist_email_node_email($email, $node) {
   $email = _og_mailinglist_rewrite_headers($email, $node, TRUE);
   $footer = _og_mailinglist_build_footer($node);
   $email = _og_mailinglist_add_footer($email, $footer);
+  $headers = $email['structure']->headers;
+  unset($email['structure']->headers);
   $email['new_email_text'] = _og_mailinglist_encode_email(array($email['structure']));
   
   // Send it off.
-  _og_mailinglist_send_raw_email($email['new_email_text']);
+  _og_mailinglist_send_raw_email($headers, $email['new_email_text'], $node);
 
   // If the sender's subscription type isn't email, give him a thread subscription.
   if (og_mailinglist_get_group_subscription_type($node->og_groups[0], $node->uid) != "email") {
@@ -367,10 +369,12 @@ function _og_mailinglist_email_comment_email($email, $node, $comment) {
   $email = _og_mailinglist_rewrite_headers($email, $node, FALSE, $comment);
   $footer = _og_mailinglist_build_footer($node);
   $email = _og_mailinglist_add_footer($email, $footer);
+  $headers = $email['structure']->headers;
+  unset($email['structure']->headers);
   $email['new_email_text'] = _og_mailinglist_encode_email(array($email['structure']));
   
   // Send it off.
-  _og_mailinglist_send_raw_email($email['new_email_text']);
+  _og_mailinglist_send_raw_email($headers, $email['new_email_text'], $node);
 }
 
 function _og_mailinglist_parse_email($email) {
@@ -704,9 +708,7 @@ function _og_mailinglist_rewrite_headers($email, $node, $new_node = FALSE, $comm
   
   $new_headers['from'] = $headers['from'];
   $new_headers['to'] = $group_node->ogm_email . "@" . variable_get('og_mailinglist_server_string', 'example.com');
-  $new_headers['bcc'] =
-    array_to_comma_delimited_string(
-      _og_mailinglist_get_subscribers($node, $new_node));
+  $new_headers['bcc'] = _og_mailinglist_get_subscribers($node, $new_node);
   $new_headers['content-type'] = $headers['content-type'];
   $new_headers['content-transfer-encoding'] =  $headers['content-transfer-encoding'];
   
@@ -816,10 +818,65 @@ function _og_mailinglist_add_footer($email, $footer) {
   return $email;
 }
 
-function _og_mailinglist_send_raw_email($raw_email) {
-  $rand_filename = rand(1000, 10000000000);
-  file_put_contents("/tmp/" . $rand_filename, $raw_email . "\n");
-  system("/usr/sbin/sendmail -t < /tmp/" . $rand_filename);
+function _og_mailinglist_send_raw_email($headers, $body, $node) {
+  $mailer = og_mailinglist_create_mailer();
+  //$mailer->SMTPDebug  = 2;
+  $mailer->ClearAddresses();
+
+  foreach($headers as $key => $value) {
+    switch ($key) {
+      case 'date':
+	$mailer->MessageDate = $value;
+        break;
+      case 'Message-ID':
+        $mailer->MessageID = $value;
+        break;
+      case 'subject':
+	$mailer->Subject = $value;
+        break;
+      case 'to':
+        if (preg_match("/(^<)*<(.*?)>/", $value, $matches)) { 
+          $mailer->AddAddress($matches[1], $matches[2]);
+        } else
+          $mailer->AddAddress($value);
+        break;
+      case 'cc':
+        if (preg_match("/(^<)*<(.*?)>/", $value, $matches)) { 
+          $mailer->AddCC($matches[1], $matches[2]);
+        } else
+          $mailer->AddCC($value);
+        break;
+      case 'bcc':
+	print_r($value);
+        foreach($value as $recipient) {
+          $mailer->AddDeliverTo($recipient);
+        }
+        break;
+      case 'from':
+        if (preg_match("/([^<]*)<(.*?)>/", $value, $matches)) { 
+          $mailer->From = $matches[2];
+          $mailer->FromName = $matches[1];
+        } else
+          $mailer->From = $value;
+        break;
+      default:
+        $mailer->AddCustomHeader($key . ':' . $value);
+    }
+  }
+
+  $mailer->Body = $body;
+
+  $success = $mailer->Send();
+  
+  if ($success) {
+    $parent_message_id = _og_mailinglist_get_thread_parent_messageid($email['headers']['in-reply-to']);
+    og_mailinglist_log_email_sent('web', $node->nid, $comment->cid, $mailer->MessageID, $headers['in_reply_to'], $headers['References'], $parent_message_id);
+  }
+  else {
+    watchdog('og_mailinglist', "OG_Mailinglist couldn't send a new node email.", NULL,
+             WATCHDOG_ERROR);
+  }
+  
 }
 
 /*
diff --git a/og_mailinglist_utilities.inc b/og_mailinglist_utilities.inc
index ce73965..eab20ff 100644
--- a/og_mailinglist_utilities.inc
+++ b/og_mailinglist_utilities.inc
@@ -274,6 +274,21 @@ function og_mailinglist_phpmailer_load_library() {
   return class_exists('PHPMailer');
 }
 
+/**
+ * Gets the directory in which PHPMailer is stored (for plugins)
+ *
+ * @return
+ *  TRUE if the PHPMailer library is loaded, FALSE otherwise.
+ */
+function og_mailinglist_get_phpmailer_plugin_dir() {
+  // First, try using libraries module.
+  if (module_exists('libraries')) {
+    // Let's see if PHPMailer is really available from libraries.
+    return './'. libraries_get_path('phpmailer') . '/';
+  }
+  return './'. drupal_get_path('module', 'og_mailinglist') .'/phpmailer/';
+}
+
 function og_mailinglist_mimeDecode_load_library() {
   if (!class_exists('Mail_mimeDecode')) {
     // First we'll try grabbing the file from a few default pear install locations.
