<?php

include('Mail.php');
include('Mail/mime.php');

class MailMod{
	var $ArrMsSp = '';
  var $AddressFrom = '';
  var $AddressSubject = '';
  var $AddressTo = '';
  var $AddressMailServer = '';

	function MailMod($ArrMsSp){
		$this->ArrMsSp = $ArrMsSp;
		return true;
	}

	function MailSend($VarHtml = ''){
  //    $text = 'Text version of email';
  //    $html = '<html><body>HTML version of email</body></html>';
  //    $file = '/home/richard/example.php';
    $crlf = "\n";
    $hdrs = array(
                  'From'    => $this->AddressFrom,
                  'Subject' => $this->AddressSubject
                  );

    $mime = new Mail_mime($crlf);

    //$mime->setTXTBody($text);
    $mime->setHTMLBody($VarHtml);
    //$mime->addAttachment($file, 'text/plain');

    //do not ever try to call these lines in reverse order
    $body = $mime->get(array('text_charset' => 'utf-8', 'html_charset' => 'utf-8', 'head_charset' => 'utf-8'));
    $hdrs = $mime->headers($hdrs);


    $params["host"]    = $this->AddressMailServer;
//$params["auth"]    = TRUE; // note: there are *no delimiters*

// note: there are *no delimiters* for DIGEST-MD5 either.
// If you want to use PLAIN,
// you have to use delimiters like this: 'PLAIN'
//$params["auth"]    = DIGEST-MD5;
//$params["username"]    = 'yourusername';
//$params["password"]    = 'yourpassword';
//$params["localhost"]= 'This.may.be.yourIP';
    $mail =& Mail::factory('smtp', $params);
    //$mail =& Mail::factory('mail');
    if('' != $this->AddressTo){
      $mail->send($this->AddressTo, $hdrs, $body);
    }
  }
}
?>