Class simpleMail {
var $parts = array();
var $to = '';
var $from = '';
var $headers = '';
var $subject = '';
var $body = '';
var $filename = "";
var $file = "";
function clear() {
$this->parts = array();
$this->to = "";
$this->from = "";
$this->subject = "";
$this->body = "";
$this->headers = "";
$this->filename = "";
$this->file = "";
}
function send() {
// main headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8'. "\r\n";
// add headers
$headers .= 'To:'.$this->to. "\r\n";
$headers .= 'From:'.$this->from. "\r\n";
$headers .= 'Subject:=?utf-8?B?'.base64_encode($this->subject). "?=\n";
if($this->file && $this->filename){
$fp = fopen($this->file, "r");
$file = fread($fp, filesize($this->file));
$file = chunk_split(base64_encode($file));
$filename = basename($this->filename);
$headers .= "Content-type: application/msword; name=$filename\r\n";
$headers .= "Content-transfer-encoding:base64\r\n\r\n";
$headers .= $file. "\r\n\r\n";
}
mail($this->to, "", $this->body, $headers);
}
function __set( $name, $value ){
foreach ( get_class_vars($this) as $var ) {
$this->$var = $value;
}
}
}
$mailer = new simpleMail();
$mailer->from = 'от дяди васи';
$mailer->subject = 'Тема';
$mailer->filename = "report.xls";
$mailer->file = "x:\report.xls";
$mailer->to = "bill_gates@microsoft.com";
$mailer -> body = "";
$mailer->send();
Те повезло что меня на работе недавно припахали сделать )