示例#1
0
function drupal_mail_wrapper($message)
{
    $mimeheaders = array();
    foreach ($message['headers'] as $name => $value) {
        $mimeheaders[] = $name . ': ' . mime_header_encode($value);
    }
    $mail = new CVWOEmail(YMCA_NOTIFICATION_EMAIL_FROM, mime_header_encode($message['subject']));
    $mail->setContent($message['body']);
    return $mail->sendImmediate($message['to']);
}
示例#2
0
function send_mime_mail($name_from, $email_from, $name_to, $email_to, $data_charset, $send_charset, $subject, $body)
{
    $to = mime_header_encode($name_to, $data_charset, $send_charset) . '<' . $email_to . '>';
    $subject = mime_header_encode($subject, $data_charset, $send_charset);
    $from = mime_header_encode($name_from, $data_charset, $send_charset) . '<' . $email_from . '>';
    if ($data_charset != $send_charset) {
        $body = iconv($data_charset, $send_charset, $body);
    }
    $headers = "From: {$from}\r\n";
    $headers .= "Content-type: text/plain; charset={$send_charset}\r\n";
    $headers .= "Mime-Version: 1.0\r\n";
    return @mail($to, $subject, $body, $headers);
}
 function send()
 {
     $dc = $this->data_charset;
     $sc = $this->send_charset;
     $enc_to = mime_header_encode($this->to_name, $dc, $sc) . ' <' . $this->to_email . '>';
     $enc_subject = mime_header_encode($this->subject, $dc, $sc);
     $enc_from = mime_header_encode($this->from_name, $dc, $sc) . ' <' . $this->from_email . '>';
     $enc_body = $dc == $sc ? $this->body : iconv($dc, $sc . '//IGNORE', $this->body);
     $headers .= "Content-type: " . $this->type . "; charset=" . $sc . "\r\n";
     // тип и кодировка
     $headers .= "From: " . $enc_from . "\r\n";
     // от кого письмо
     return mail($enc_to, $enc_subject, $enc_body, $headers);
 }
示例#4
0
 public function composeMessage($message)
 {
     $mimeheaders = array();
     $message['headers']['To'] = $message['to'];
     foreach ($message['headers'] as $name => $value) {
         $mimeheaders[] = $name . ': ' . mime_header_encode($value);
     }
     $line_endings = Settings::get('mail_line_endings', PHP_EOL);
     $output = join($line_endings, $mimeheaders) . $line_endings;
     // 'Subject:' is a mail header and should not be translated.
     $output .= 'Subject: ' . $message['subject'] . $line_endings;
     // Blank line to separate headers from body.
     $output .= $line_endings;
     $output .= preg_replace('@\\r?\\n@', $line_endings, $message['body']);
     return $output;
 }
 /**
  * Sends an email message.
  *
  * @param array $message
  *   A message array, as described in hook_mail_alter().
  *
  * @return bool
  *   TRUE if the mail was successfully accepted, otherwise FALSE.
  *
  * @see http://php.net/manual/en/function.mail.php
  * @see drupal_mail()
  */
 public function mail(array $message)
 {
     // If 'Return-Path' isn't already set in php.ini, we pass it separately
     // as an additional parameter instead of in the header.
     if (isset($message['headers']['Return-Path'])) {
         $return_path_set = strpos(ini_get('sendmail_path'), ' -f');
         if (!$return_path_set) {
             $message['Return-Path'] = $message['headers']['Return-Path'];
             unset($message['headers']['Return-Path']);
         }
     }
     $mimeheaders = array();
     foreach ($message['headers'] as $name => $value) {
         $mimeheaders[] = $name . ': ' . mime_header_encode($value);
     }
     $line_endings = Settings::get('mail_line_endings', PHP_EOL);
     // Prepare mail commands.
     $mail_subject = mime_header_encode($message['subject']);
     // Note: email uses CRLF for line-endings. PHP's API requires LF
     // on Unix and CRLF on Windows. Drupal automatically guesses the
     // line-ending format appropriate for your system. If you need to
     // override this, adjust $settings['mail_line_endings'] in settings.php.
     $mail_body = preg_replace('@\\r?\\n@', $line_endings, $message['body']);
     // For headers, PHP's API suggests that we use CRLF normally,
     // but some MTAs incorrectly replace LF with CRLF. See #234403.
     $mail_headers = join("\n", $mimeheaders);
     $request = \Drupal::request();
     // We suppress warnings and notices from mail() because of issues on some
     // hosts. The return value of this method will still indicate whether mail
     // was sent successfully.
     if (!$request->server->has('WINDIR') && strpos($request->server->get('SERVER_SOFTWARE'), 'Win32') === FALSE) {
         // On most non-Windows systems, the "-f" option to the sendmail command
         // is used to set the Return-Path. There is no space between -f and
         // the value of the return path.
         $additional_headers = isset($message['Return-Path']) ? '-f' . $message['Return-Path'] : '';
         $mail_result = @mail($message['to'], $mail_subject, $mail_body, $mail_headers, $additional_headers);
     } else {
         // On Windows, PHP will use the value of sendmail_from for the
         // Return-Path header.
         $old_from = ini_get('sendmail_from');
         ini_set('sendmail_from', $message['Return-Path']);
         $mail_result = @mail($message['to'], $mail_subject, $mail_body, $mail_headers);
         ini_set('sendmail_from', $old_from);
     }
     return $mail_result;
 }
示例#6
0
function send_mime_mail($name_from, $email_from, $name_to, $email_to, $data_charset, $send_charset, $subject, $body, $html = FALSE, $reply_to = FALSE)
{
    $to = $email_to;
    $subject = mime_header_encode($subject, $data_charset, $send_charset);
    $from = mime_header_encode($name_from, $data_charset, $send_charset) . ' <' . $email_from . '>';
    if ($data_charset != $send_charset) {
        $body = iconv($data_charset, $send_charset, $body);
    }
    $headers = "From: {$from}\r\n";
    $type = $html ? 'html' : 'plain';
    $headers .= "Content-type: text/{$type}; charset={$send_charset}\r\n";
    $headers .= "Mime-Version: 1.0\r\n";
    if ($reply_to) {
        $headers .= "Reply-To: {$reply_to}";
    }
    return mail($to, $subject, $body, $headers);
}
 function send()
 {
     $dc = $this->data_charset;
     $sc = $this->send_charset;
     //Кодируем поля адресата, темы и отправителя
     $enc_to = mime_header_encode($this->to_name, $dc, $sc) . ' <' . $this->to_email . '>';
     $enc_subject = mime_header_encode($this->subject, $dc, $sc);
     $enc_from = mime_header_encode($this->from_name, $dc, $sc) . ' <' . $this->from_email . '>';
     //Кодируем тело письма
     $enc_body = $dc == $sc ? $this->body : iconv($dc, $sc . '//IGNORE', $this->body);
     //Оформляем заголовки письма
     $headers = '';
     $headers .= "Mime-Version: 1.0\r\n";
     $headers .= "Content-type: " . $this->type . "; charset=" . $sc . "\r\n";
     $headers .= "From: " . $enc_from . "\r\n";
     //Отправляем
     return mail($enc_to, $enc_subject, $enc_body, $headers);
 }
示例#8
0
function send_mail($to, $thm, $html, $from = MAIL_FROM, $file_path = false, $send_name = 'default.txt')
{
    $headers = "";
    $multipart = "";
    if ($file_path) {
        $fp = fopen($file_path, "r");
        if (!$fp) {
            preprint("Файл " . $file_path . " не может быть прочитан");
            return false;
        }
        $file = fread($fp, filesize($file_path));
        fclose($fp);
    }
    $boundary = "--" . md5(uniqid(time()));
    // генерируем разделитель
    $headers .= "From: " . $from . "\n";
    $headers .= "Reply-To: " . $from . "\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/mixed; boundary=\"" . $boundary . "\"\n";
    $multipart .= "--" . $boundary . "\n";
    $kod = 'utf-8';
    $multipart .= "Content-Type: text/html; charset=" . $kod . "\n";
    $multipart .= "Content-Transfer-Encoding: Quot-Printed\n\n";
    $multipart .= $html . "\n\n";
    if ($file_path) {
        $message_part = "--" . $boundary . "\n";
        $message_part .= "Content-Type: application/octet-stream\n";
        $message_part .= "Content-Transfer-Encoding: base64\n";
        $message_part .= "Content-Disposition: attachment; filename = \"" . $send_name . "\"\n\n";
        $message_part .= chunk_split(base64_encode($file)) . "\n";
        $multipart .= $message_part;
    }
    $multipart .= "--" . $boundary . "--\n";
    if (!mail($to, mime_header_encode($thm, "utf-8", "utf-8"), $multipart, $headers)) {
        preprint("Письмо не отправлено.");
        return false;
    } else {
        return true;
    }
}
示例#9
0
 /**
  * Delivery callback; transfer the file inline.
  *
  * @param mixed $file
  */
 public static function deliverFileTransfer($file)
 {
     if (is_int($file)) {
         drupal_deliver_html_page($file);
         return;
     } elseif (!is_object($file) || !is_file($file->uri) || !is_readable($file->uri)) {
         drupal_deliver_html_page(MENU_NOT_FOUND);
         return;
     }
     // @todo Figure out if any other headers should be added.
     $headers = array('Content-Type' => mime_header_encode($file->filemime), 'Content-Disposition' => 'inline', 'Content-Length' => $file->filesize);
     // Let other modules alter the download headers.
     //drupal_alter('file_download_headers', $headers, $file);
     // Let other modules know the file is being downloaded.
     module_invoke_all('file_transfer', $file->uri, $headers);
     foreach ($headers as $name => $value) {
         drupal_add_http_header($name, $value);
     }
     $fd = fopen($file->uri, 'rb');
     if ($fd !== FALSE) {
         while (!feof($fd)) {
             print fread($fd, DRUPAL_KILOBYTE);
         }
         fclose($fd);
     } else {
         watchdog('favicon', 'Unable to open @uri for reading.', array('@uri' => $file->uri));
         drupal_deliver_html_page(MENU_NOT_FOUND);
         return;
     }
     // Perform end-of-request tasks.
     if (static::canCacheFile($file)) {
         drupal_page_footer();
     } else {
         drupal_exit();
     }
 }
示例#10
0
文件: functions.php 项目: realtim/mmb
function send_mime_mail($name_from, $email_from, $name_to, $email_to, $data_charset, $send_charset, $subject, $body, $html = FALSE)
{
    $to = mime_header_encode($name_to, $data_charset, $send_charset) . " <{$email_to}>";
    $subject = mime_header_encode($subject, $data_charset, $send_charset);
    $from = mime_header_encode($name_from, $data_charset, $send_charset) . " <{$email_from}>";
    if ($data_charset != $send_charset) {
        $body = iconv($data_charset, $send_charset, $body);
    }
    $headers = "From: {$from}\r\n";
    $type = $html ? 'html' : 'plain';
    $headers .= "Content-type: text/{$type}; charset={$send_charset}\r\n";
    $headers .= "Mime-Version: 1.0\r\n";
    // 09/09/2013 Добавил атрибут Return-Path (пятым параметром)
    return mail($to, $subject, $body, $headers, "-f" . $email_from);
}
示例#11
0
文件: func.php 项目: retspen/VoteFoto
function send_mime_mail($name_from,
                        $email_from,
                        $name_to,
                        $email_to,
                        $data_charset,
                        $send_charset,
                        $subject,
                        $body
                        ) {
  $to = mime_header_encode($name_to, $data_charset, $send_charset)
                 . ' <' . $email_to . '>';
  $subject = mime_header_encode($subject, $data_charset, $send_charset);
  $from =  mime_header_encode($name_from, $data_charset, $send_charset)
                     .' <' . $email_from . '>';
  if($data_charset != $send_charset) {
    $body = iconv($data_charset, $send_charset, $body);
  }
  $headers = "From: $from\r\n";
  $headers .= "Content-type: text/html; charset=$send_charset\r\n";

  return mail($to, $subject, $body, $headers);
}
示例#12
0
 function send_mime_mail(
  $name_from, // имя отправителя
  $email_from, // email отправителя
  $name_to, // имя получателя
  $email_to, // email получателя
  $data_charset, // кодировка переданных данных
  $send_charset, // кодировка письма
  $subject, // тема письма
  $body, // текст письма
  $html = FALSE, // письмо в виде html или обычного текста
  $reply_to = FALSE
 ) {
  $to = mime_header_encode($name_to, $data_charset, $send_charset).' <' . $email_to.'>';
  $subject = mime_header_encode($subject, $data_charset, $send_charset);
  $from =  mime_header_encode($name_from, $data_charset, $send_charset).' <'.$email_from.'>';
  if($data_charset != $send_charset) {
   $body = iconv($data_charset, $send_charset, $body);
  }
  $headers = "From: ".$from."\r\n";
  $type = ($html) ? 'html' : 'plain';
  $headers .= "Content-type: text/".$type."; charset=".$send_charset."\r\n";
  $headers .= "Mime-Version: 1.0\r\n";
  if ($reply_to) {
   $headers .= "Reply-To: ".$reply_to;
  }
  return mail($to, $subject, $body, $headers);
 }
示例#13
0
 /**
  * Performs the sending of invitation emails.
  * @param array $args Form configuration arguments
  * @param array $auth Authorisation tokens
  * @todo Integrate with notifications for logged in users.
  */
 private static function sendInvites($args, $auth)
 {
     $emails = helper_base::explode_lines($_POST['invitee_emails']);
     // first task is to populate the groups_invitations table
     $base = uniqid();
     $success = true;
     $failedRecipients = array();
     foreach ($emails as $idx => $email) {
         $values = array('group_invitation:group_id' => $_GET['group_id'], 'group_invitation:email' => $email, 'group_invitation:token' => $base . $idx, 'website_id' => $args['website_id']);
         $s = submission_builder::build_submission($values, array('model' => 'group_invitation'));
         $r = data_entry_helper::forward_post_to('group_invitation', $s, $auth['write_tokens']);
         $pathParam = function_exists('variable_get') && variable_get('clean_url', 0) == '0' ? 'q' : '';
         $rootFolder = data_entry_helper::getRootFolder() . (empty($pathParam) ? '' : "?{$pathParam}=");
         $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
         $acceptUrl = $protocol . $_SERVER['HTTP_HOST'] . $rootFolder . $args['accept_invite_path'] . (empty($pathParam) ? '?' : '&') . 'token=' . $base . $idx;
         $body = $_POST['invite_message'] . "<br/><br/>" . '<a href="' . $acceptUrl . '">' . lang::get('Accept this invitation') . '</a>';
         $message = array('id' => 'iform_group_invite', 'to' => implode(',', $emails), 'subject' => 'Invitation to join a recording group', 'body' => $body, 'headers' => array('MIME-Version' => '1.0', 'Content-type' => 'text/html; charset=iso-8859-1'));
         $mimeheaders = array();
         foreach ($message['headers'] as $name => $value) {
             $mimeheaders[] = $name . ': ' . mime_header_encode($value);
         }
         $thismailsuccess = mail($message['to'], mime_header_encode($message['subject']), str_replace("\r", '', $message['body']), join("\n", $mimeheaders));
         if (!$thismailsuccess) {
             $failedRecipients[$message['to']] = $acceptUrl;
         }
         $success = $success && $thismailsuccess;
     }
     if ($success) {
         drupal_set_message(lang::get('Invitation emails sent'));
     } else {
         drupal_set_message(lang::get('The emails could not be sent due to a server configuration issue. Please contact the site admin. ' . 'The list below gives the emails and the links you need to send to each invitee which they need to click on in order to join the group.'), 'warning');
         $list = array();
         foreach ($failedRecipients as $email => $link) {
             $list[] = lang::get("Send link {1} to {2}.", $link, $email);
         }
         drupal_set_message(implode('<br/>', $list), 'warning');
     }
     drupal_goto($args['redirect_on_success']);
 }
示例#14
0
文件: email.php 项目: longpoll/jsRKSI
$_SESSION['hash'] = $hash;
$first_name = $p['first_name'];
$last_name = $p['last_name'];
$address = $p['address'];
$query = "SELECT * FROM `js_catalog` WHERE 1!=1";
for ($i = 0; $i < sizeof($cIdE); $i++) {
    $query .= " OR `cId`=" . $cIdE[$i];
}
$d = SQL($query);
SQL("INSERT INTO `js_card`(`cId`, `count`, `hash`, `email`, `first_name`, `last_name`, `address`) VALUES ('" . $cId . "', '" . $count . "', '" . $hash . "', '" . $email . "', '" . $first_name . "', '" . $last_name . "', '" . $address . "')");
$m = '<a href="http://js.apicat.ru/' . $hash . '">Перейти к заказу</a>';
$m .= '<br/>Имя: ' . $first_name;
$m .= '<br/>Фамилия: ' . $last_name;
$m .= '<br/>Адрес: ' . $address;
$to = $email;
$text = $m;
$subject = "Заказ оформлен!";
$from_name = "*****@*****.**";
$dc = "UTF-8";
$sc = "windows-1251";
$enc_to = mime_header_encode($to, $dc, $sc) . ' <' . $to . '>';
$enc_subject = mime_header_encode($subject, $dc, $sc);
$enc_from = mime_header_encode($from_name, $dc, $sc) . ' <' . $from_name . '>';
$enc_body = $dc == $sc ? $text : iconv($dc, $sc . '//IGNORE', $text);
$headers = "Mime-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=windows-1251\r\n";
$headers .= "From: " . $enc_from . "\r\n";
mail($enc_to, $enc_subject, $enc_body, $headers);
header("Location: /" . $hash);
?>
		
示例#15
0
 /**
  * Queues a email message fro delivery.
  *
  * @ingroup phplist_mail
  * @param $lids An array of id values of the lists to send message to.
  */
 function phplist_send_mail($lids, $mid, $subject, $message_type, $body_header, $body, $footer, $from, $timestamp = null)
 {
     $message = new BlastMessage($this->_dbcon);
     if ($mid) {
         $message->readData($mid);
     }
     $message_data = array('subject' => mime_header_encode($subject), 'fromfield' => $from, 'owner' => $_SERVER['REMOTE_USER'], 'entered' => date('Y-m-d'), 'modified' => date('YmdHis'));
     $message->setFormat($message_type);
     $message->setEmbargo($timestamp);
     $message->setMessage($body, $body_header, $footer);
     $message->submit();
     foreach ($lids as $list_id) {
         $message->queue($list_id);
     }
 }
示例#16
0
function sent_email_new($send_to, $message, $file, $subject, $send_from)
{
    /*
    	<div id="h">
    		 <img src="http://'.ADRESS_SITE.'/pic/logo.png" alt="" />
    	</div>
    */
    $message = '
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<!-- (c) Wezom web-студия | http://www.wezom.com.ua/ -->
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Web-студия «Wezom»</title>
		</head>
		<body>
		<style type="text/css">
			body,html { padding:0; margin:0}
			body { font:13px/1.2em Arial, Helvetica, sans-serif;}
			h1 { font:26px/1.2em Arial, Helvetica, sans-serif; padding:0; margin:0}
			h2 { font:22px/1.2em Arial, Helvetica, sans-serif; padding:0; margin:0}
			h3 { font:20px/1.2em Arial, Helvetica, sans-serif; padding:0; margin:0}
			table {border-collapse: collapse; }
			table { margin:0}
			table th {color: #999;font-weight: bold; padding: 6px 6px 5px;text-align: left;  border-bottom: 1px solid #ccc; font:italic 14px/1.2em Arial, Helvetica, sans-serif;}
			table td {padding: 6px 6px 5px; border:0;vertical-align: top;line-height: 1.2em; border-bottom: 1px solid #ccc;}
			table tr:nth-child(even) {background-color: #f7f7f7;}
			#h {padding:10px 0; border-bottom:1px solid #ccc; margin:0 10px 0}
			#c {padding:10px 10px 10px;}
			#f {padding:10px 0; border-top:1px solid #ccc; margin:0 10px 0}
		</style>
			<div id="c">
								 
			</div>
				' . $message . '
			
		</body>
		</html>	
	';
    //--------------------------------------------------------------
    //--------------------------------------------------------------
    //--------------------------------------------------------------
    /*
        $send_time =  date("d.m.Y в H:i:s");
        $headers   =  "MIME-Version: 1.0\r\n";
        $headers  .=  "Content-type: text/html; charset=utf-8\r\n";
        $headers  .=  "From:  ".$send_from."\r\n";
        $headers  .=  "Reply-To: ".$send_from."\r\n";
        $message   =  $html;
    $subject = '=?utf-8?B?'.base64_encode($subject).'?=';
        $result    =  @mail($send_to, $subject, $message, $headers);
        if ($result)  return true;
    */
    $send_charset = $data_charset = 'utf-8';
    $to = mime_header_encode($send_to, $data_charset, $send_charset) . ' <' . $send_to . '>';
    $subject = mime_header_encode($subject, $data_charset, $send_charset);
    $from = mime_header_encode($send_from, $data_charset, $send_charset) . ' <' . $send_from . '>';
    if ($data_charset != $send_charset) {
        $message = iconv($data_charset, $send_charset, $message);
    }
    $headers = "From: {$from}\r\n";
    $headers .= "Content-type: text/html; charset={$send_charset}\r\n";
    $headers .= "Mime-Version: 1.0\r\n";
    return mail($to, $subject, $message, $headers);
}
示例#17
0
文件: net.php 项目: tapiau/muyo
 /**
  * @param string $name
  * @param mixed $value
  * @return string
  */
 function mime_header_entry_map($value, $name)
 {
     if (debug_assert(is_string($name), "Invalid parameters ")) {
         switch ($name) {
             case 'Content-Type':
                 arrayize($value);
                 $value = mime_header_contenttype_map($value[0], array_filter_key($value, tuple_get(1, 'is_string')));
                 break;
             case 'Content-Disposition':
                 $value['name'] = mime_header_encode($value['name']);
                 $value = mime_header_contenttype_map($value[0], array_filter_key($value, tuple_get(1, 'is_string')));
                 break;
             default:
                 $dump = var_dump_human_compact($value);
                 debug_enforce(is_string($value), "Could not map '{$name}'=>'{$dump}'");
                 break;
         }
         return "{$name}: {$value}\r\n";
     } else {
         return '';
     }
 }
 public function mail(array $message)
 {
     if (!empty($message[self::PROVIDER_KEY])) {
         $provider = $message[self::PROVIDER_KEY];
     } else {
         $provider = self::PROVIDER_DEFAULT;
     }
     if (!($smtp = $this->getInstance($provider))) {
         return false;
     }
     // SMTP basically does not care about message format. MIME is the
     // standard for everybody, so just prey that the previous formatter
     // did it right, but in all cases, we don't have to attempt any
     // formatting ourselves, this would be an serious error vulgaris
     // that every one seem to do... God I hate people.
     if (empty($message['body'])) {
         watchdog('netsmtp', "Sending an empty mail", array(), WATCHDOG_WARNING);
         $message['body'] = '';
     }
     if (is_array($message['body'])) {
         $message['body'] = implode("\n", $message['body']);
     }
     if (empty($message['headers']['Subject'])) {
         if (variable_get('netsmtp_subject_encode', true)) {
             $message['headers']['Subject'] = mime_header_encode($message['subject']);
         } else {
             $message['headers']['Subject'] = $message['subject'];
         }
     }
     // Drupal black magic: we have to find the sender FROM into the
     // headers, that's a shame, but that's that. And if we can't find
     // any then do some black magic by ourselves
     if (empty($message['headers']['From'])) {
         if (empty($message['headers']['Reply-To'])) {
             $this->setError("No 'From' nor 'Reply-To' in mail");
             return false;
         } else {
             $this->setError("No 'From' in mail, using 'Reply-To' instead", WATCHDOG_INFO);
             $from = $this->catchAddressesInto($message['headers']['Reply-To']);
             $from = reset($from);
         }
     } else {
         $from = $this->catchAddressesInto($message['headers']['From']);
         $from = reset($from);
     }
     if (empty($from)) {
         $this->setError("FROM invalid or not found");
         return false;
     }
     if ($this->PEAR->isError($e = $smtp->mailFrom($from))) {
         $this->setError($e);
         return false;
     }
     $atLeastOne = false;
     foreach ($this->catchAddressesInto($message['to']) as $to) {
         if ($this->PEAR->isError($e = $smtp->rcptTo($to))) {
             $this->setError($e);
         } else {
             $atLeastOne = true;
         }
     }
     if (!$atLeastOne) {
         $this->setError("No RCPT was accepted by the SMTP server", WATCHDOG_ERROR);
         return false;
     }
     // Also note that the Net_SMTP library wants headers to be a string too
     $headers = array();
     foreach ($message['headers'] as $name => $value) {
         if (is_array($value)) {
             foreach ($value as $_value) {
                 $headers[] = $name . ": " . $_value;
             }
         } else {
             $headers[] = $name . ": " . $value;
         }
     }
     // And the ugly part is, append body like a real Viking would do!
     $status = true;
     if ($this->PEAR->isError($e = $smtp->data($message['body'], implode("\n", $headers)))) {
         $this->setError($e);
         $status = false;
     }
     if (variable_get('netsmtp_debug_mime')) {
         $path = variable_get('netsmtp_debug_mime_path', 'temporary://netsmtp');
         $path .= '/' . date('Y-m-d');
         file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
         file_put_contents($path . '/' . $provider . '-' . date('Y_m_d-H_i_s') . '.mbox', implode("\n", $headers) . "\n\n" . $message['body']);
     }
     $smtp->disconnect();
     return $status;
 }