o tak:
<?php
/* This is Version 1.4
* Notes from rozhik@ziet.zhitomir.ua 25 Mar 2000:
* Improvements: Multi attachmends in one e-mail, ability to post html & plain trext, up to 3x speed improved.
* USSAGE - mimetype example for attacment
* $m = new CMIMEMail($to,$from,$subject);
* $m->mailbody("This is simply text","<html><body><h1>This is HTML text</h1>");
* $m->attach("example.html","text/html",$filebody);
* $m->attachFile("resume.gif","image/gif");
* $m->send();
*******
* Notes from maho
* i added $cc to this.
*********
* To Do:
* 1 Test with different Mail clients
*/
class CMIMEMail {
var $to;
var $boundary;
var $smtp_headers;
var $filename_real;
var $body_plain;
var $body_html;
var
$atcmnt;
var $atcmnt_type;
function CMIMEMail($to,$cc,$from,$subject,$priority=3) {
$this->to=$to; $this->from=$from; $this->cc=$cc;
$this->subject=$subject; $this->priority=$priority;
$this->boundary="----=_NextPart_".time()."_".md5(time())."_"; }
function mailbody( $plain, $html="" ) {
$this->body_plain=$plain;
$this->body_html=$html;
}
function attach( $name, $content_type, $data ) {
}
function attachfile( $fname, $content_type ) {
$this->attachfile_raw($fname,$fname,$content_type);
}
function attachfile_raw( $fname, $mailFileName, $content_type ) {
if($f=@fopen($fname,"r")) { $this->atcmnt_type[$mailFileName]=$content_type;
}
}
function clear() {
}
function makeheader() {
$out ="From: ".$this->from."n";
$out.="Reply-To: ".$this->from."n";
$out.="CC: ".$this->cc."n";
$out.="MIME-Version: 1.0n".
"Content-Type: multipart/mixed;nt boundary="".$this->boundary.""n".
"X-Priority: ".$this->priority."n".
"X-Mailer: php_pAgEmAil(phpMimeMail+rymo)(http://www.pagema.net)n";
return $out;
}
function makebody() {
$boundary2= "----=_NextAttachedPart_".time()."_".md5(time()+101)."_"; $out="";
if( " ".$this->body_html!=" " ) {
$out="nThis is a multi-part message in MIME format.nn";
$out.="--".$this->boundary."nContent-Type: multipart/alternative;ntboundary="$boundary2"n";
$out.="$body_plann".
"--$boundary2nContent-Type: text/plainn".
# "Content-Disposition: inlinen".
"Content-Transfer-Encoding: quoted-printablenn".
$this->body_plain.
"nn--$boundary2n".
"Content-Type: text/htmln".
# "Content-Disposition: attachment;ntfilename="message.html"n".
"Conent-Transfer-Encoding: quoted-printablen".
"n$this->body_htmlnn".
"--$boundary2--n";
} else {
$out="nn".$this->body_plain."nn";
$out.="--".$this->boundary."n".
"Content-Type: text/plainn".
"Content-Transfer-Encoding: quoted-printablenn".
$this->body_plain.
"nn--".$this->boundary.
"n";
}
reset( $this->atcmnt_type); while( list
($name, $content_type) = each($this->atcmnt_type) ) { $out.="n--".$this->boundary."nContent-Type: $content_typenContent-Transfer-Encoding: base64nContent-Disposition: attachment; filename="$name"nn".
}
}
$out.="n--".$this->boundary."--n";
return $out;
}
function send(){
mail( $this->to, $this->subject, $this->makebody(),$this->makeheader() ); }
function sendto($email){
mail( $email, $this->subject, $this->makebody(),$this->makeheader() ); }
}
?>
wygląda klasa z której ja korzystam
PS. nie chce korzystać z PEAR. wie ktoś jak to zrobić czy etam?
Umysły tego forum. POMÓŻCIE