--- upload/include/class.misc.php 2008-01-29 10:01:35.000000000 +0100 +++ osticket-dev/include/class.misc.php 2008-03-05 12:24:11.000000000 +0100 @@ -54,24 +54,45 @@ } /* Send email out after minor cleanups..*/ - function sendmail($to, $subject, $message, $fromaddress,$fromname='', $xheaders = '') { - //TODO: provide an option to use SMTP server. Log all outgoign emails?? - - $eol="\n"; - $fromname=$fromname?$fromname:$fromaddress; - //do some cleanup...avoid stupid errors. - $to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to)); - $subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject)); - $message = preg_replace("/(\r\n|\r)/s", "\n", trim($message)); - #Headers - $headers .= "From: ".$fromname."<".$fromaddress.">".$eol; - $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol; - $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol; - $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol; - $headers .= "X-Mailer: osTicket v 1.6".$eol; - if($xheaders) $headers .= $xheaders; - //echo "[$to,$subject,$message ".$headers.']'; - mail($to,$subject,$message,trim($headers)); + function sendmail($to, $subject, $message, $fromaddress,$fromname='', $xheaders = '') { + //Patch etienne zend framework + + //mail creation + require_once 'Zend/Mail.php'; + $mail = new Zend_Mail(); + + + $mail->setFrom($fromaddress, $fromname?$fromname:$fromaddress); + $mail->addTo($to,""); + $mail->setSubject($subject); + $mail->setBodyText($message); + + //for the mail transport + require_once 'Zend/Mail/Transport/Smtp.php'; + + if( MAILTYPE == 'SMTP') { + $config = array(); + if( MAILAUTH != ''){ //if the smtp need auth + $config['auth'] = MAILAUTH; + $config['username'] = MAILUSER; + $config['password'] = MAILPASSWORD; + } + if( MAILPORT != ''){ + $config['port'] = MAILPORT; + } + if( MAILSSL != ''){ + $config['ssl'] = MAILSSL; + } + + $tr = new Zend_Mail_Transport_Smtp(MAILHOST, $config); + + // make the transport the deault transport + Zend_Mail::setDefaultTransport($tr); + } + + + $mail->send(); + } }