$subject, 'From' => $from, 'To' => implode(',', $to), ); // end $headers // create the message $mime = new Mail_mime("\n"); $mime->addCc(implode(',', $cc)); $mime->addBcc(implode(',', $bcc)); $mime->setTXTBody($text); $mime->setHTMLBody($html); // always call these methods in this order $body = $mime->get(); $headers = $mime->headers($headers); // create the smtp mail object $smtp_params = array( 'host' => $smtp_server, 'auth' => true, 'username' => $smtp_username, 'password' => $smtp_password, 'timeout' => 20, 'localhost' => $_SERVER['SERVER_NAME'], ); // end $smtp_params $smtp = Mail::factory('smtp', $smtp_params); // send the message $recipients = array_merge($to, $cc, $bcc); $mail = $smtp->send($recipients, $headers, $body); // check to make sure there was no error if (PEAR::isError($mail)) { return $mail->getMessage(); } // end if there was an error return true; } // end function sendMail()