How can optimise this email class
Posted: Mon Aug 09, 2004 6:53 am
I'm interested to send only text and html emails (withouth attachments) and i would like to know if there is any method to optimise this:
Any clue?
Code: Select all
<?php
class emails {
var $email_destination;
var $email_sender;
var $email_subject;
var $email_body;
var $email_headers;
var $email_error;
function processEmail($to,$from,$subject,$message,$type) {
$this->email_destination=$to; //<-- in my script here i'm checking the email structure to be ok
$this->email_sender=$from; //<-- in my script here i'm checking the email structure to be ok
$this->email_subject=$subject;
$this->email_body=$message;
$this->email_error='';
$this->headers='MIME-Version: 1.0\r\n';
if(strcasecmp($type,'html')==0) {
$this->headers .='Content-Type: text/html; charset="iso-8859-1"\r\n';
}
else {
$this->headers .='Content-Type: text/plain; charset="iso-8859-1"\r\n';
}
$headers .= "To: ".$this->email_destination." <".$this->email_destination.">\r\n";
$headers .= "From: ".$this->email_sender." <".$this->email_sender.">\r\n";
$this->sendEmail()
}
function sendEmail() {
$sent=mail($this->email_destination, $this->email_subject, $this->email_body, $headers);
if(!$sent) {
$this->email_error=$this->email_destination;
}
}
}
?>