6         var $mCharSet = "iso-8859-1";
 
   7         var $mContentType = "text/plain";
 
  12     function __construct($type='standard') {
 
  13         $this->mSendType = $type;
 
  16     function setSendType($value) {
 
  17         $this->mSendType = $value;
 
  20     function setCharSet($value) {
 
  21         $this->mCharSet = $value;
 
  24     function setContentType($value) {
 
  25         $this->mContentType = $value;
 
  28     function setReceiver($value) {
 
  29         $this->mReceiver = $value;
 
  32     function setReceiverCC($value) {
 
  33         $this->mReceiverCC = $value;
 
  36     function setSender($value) {
 
  37         $this->mSender = $value;
 
  40     function send($subject, $data) {
 
  41         $data = chunk_split(base64_encode($data));
 
  42         $subject = Mailer::mimeEncode($subject, $this->mCharSet);
 
  45                 'From' => $this->mSender,
 
  46                 'To' => $this->mReceiver);
 
  47         if (isset($this->mReceiverCC)) $headers = array_merge($headers, array(
 
  48                 'CC' => $this->mReceiverCC));
 
  49         $headers = array_merge($headers, array(
 
  50                 'Subject' => $subject,
 
  51                 'MIME-Version' => '1.0',
 
  52                 'Content-Type' => $this->mContentType.'; charset='.$this->mCharSet,
 
  53                 'Content-Transfer-Encoding' => 'BASE64',
 
  57         require_once('Mail.php');
 
  59         $recipients = $this->mReceiver;
 
  60         switch ($this->mSendType) {
 
  62                                         $mail = Mail::factory('mail');
 
  66                         // Mail_smtp does not do CC -> recipients conversion
 
  67                         if (!empty($this->mReceiverCC)) {
 
  68                                 // make exactly one space after a comma
 
  69                                 $recipients .= ', ' . preg_replace('/,[[:space:]]+/', ', ', $this->mReceiverCC);;
 
  72                         $host = defined('MAIL_SMTP_HOST') ? MAIL_SMTP_HOST : 'localhost';
 
  73                         $port = defined('MAIL_SMTP_PORT') ? MAIL_SMTP_PORT : '25';
 
  74                         $username = defined('MAIL_SMTP_USER') ? MAIL_SMTP_USER : null;
 
  75                         $password = defined('MAIL_SMTP_PASSWORD') ? MAIL_SMTP_PASSWORD : null;
 
  76                         $auth = (defined('MAIL_SMTP_AUTH') && isTrue(MAIL_SMTP_AUTH)) ? true : false;
 
  77                         $debug = (defined('MAIL_SMTP_DEBUG') && isTrue(MAIL_SMTP_DEBUG)) ? true : false;
 
  79                         $mail = Mail::factory('smtp', array ('host' => $host,
 
  81                           'username' => $username,
 
  82                           'password' => $password,
 
  88         if (defined('MAIL_SMTP_DEBUG') && isTrue(MAIL_SMTP_DEBUG))
 
  89           PEAR::setErrorHandling(PEAR_ERROR_PRINT);
 
  90         $res = $mail->send($recipients, $headers, $data);
 
  91         return (!is_a($res, 'PEAR_Error'));
 
  95      * convert to base64-string
 
  97      * @param string $in_str
 
  98      * @param string $charset
 
 101     function mimeEncode($in_str, $charset) {
 
 103            if ($out_str && $charset) {
 
 106                $start = "=?" . strtoupper($charset) . "?B?";
 
 107                $spacer = $end . "\r\n " . $start;
 
 109                $length = 75 - strlen($start) - strlen($end);
 
 110                $length = floor($length/2) * 2;
 
 112                $out_str = base64_encode($out_str);
 
 113                //$out_str = Mail::encodemime($out_str,"base64");
 
 114                //$out_str = chunk_split($out_str, $length, $spacer);
 
 116                //$spacer = preg_quote($spacer);
 
 117                //$out_str = preg_replace("/" . $spacer . "$/", "", $out_str);
 
 118                $out_str = $start . $out_str . $end;