Laurent GAY - 2012-01-14 18:30:58
Hi,
I am use those class in my project an it run perfectly.
I propose a little example to add an joint file to an email:
------------------------------------------------------------
function sendEMail($from,$to,$subject,
$body /* Test body of your email */,
$fileName /*file name propose in email*/,
$contentFile /*string content of file to send*/) {
$smtp=new smtp_class;
$smtp->host_name="smpt.phpclasses.org"; /* change with your own server */
$smtp->host_port=25;
$random_hash = md5(date('r', time()));
$extendbody.='--'.$random_hash."\n";
$Conttype='Content-Type: multipart/mixed; boundary="'.$random_hash.'"';
$extendbody.="Content-Type: text/plain;charset=iso-8859-1\r\n\n";
$extendbody.=$body."\n\n";
$extendbody.='--'.$random_hash."\n";
$finfo = new finfo(FILEINFO_MIME_TYPE);
$extendbody.='Content-Type: '.$finfo->buffer($contentFile).'; name="'.$fileName.'"'."\r\n";
$extendbody.="Content-Transfer-Encoding: base64\r\n";
$extendbody.='Content-Disposition: attachment; filename="'.$fileName.'"'."\r\n\n";
$extendbody.=chunk_split(base64_encode($contentFile));
$extendbody.='--'.$random_hash.'--'."\n";
$ret=$smtp->SendMessage($from,explode(',',$to),array("From: $from","To: $to","Subject: $Subject",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"),$Conttype),$extendbody);
if (!$ret)
throw new Exception($smtp->error);
}