Размер файла: 3.47Kb
<?
Class Email
{
var $EmailCharset = 'utf-8';
var $Emails;
var $EmailFrom = '[email protected]';
var $EmailType = 'text/plain';
var $EmailXmailer = 'TRX Mailer';
var $EmailSubject = 'Mail for Admin from site q6p.info';
var $EmailErrorTo = '[email protected]';
var $EmailReplyTo;
var $EmailMessage = 'Прочтите сообщение и проверьте файл!';
var $EmailBody;
var $EmailTo;
var $EmailFiles;
var $Headers;
var $EmailError = 0;
var $EmailErrors = '';
function BuildMessage()
{
$un_bound = "TRX".time();
$this->Headers .= "From: ".$this->EmailFrom."\n";
$this->Headers .= "Subject: ".$this->EmailSubject."\n";
if($this->EmailErrorTo != ''){
$this->Headers .= "Errors-To: ".$this->EmailErrorTo."\n";
}
$this->Headers .= "X-Mailer: ".$this->EmailXmailer."\n";
$this->Headers .= "MIME-Version: 1.0\n";
$this->Headers .= "Content-Type: multipart/mixed; boundary=".$un_bound."\n\n";
$this->EmailBody = "--".$un_bound."\n";
$this->EmailBody .= "Content-Type: ".$this->EmailType."; charset=".$this->EmailCharset."\n";
$this->EmailBody .= "Content-Transfer-Encoding: 8bit\n\n";
$this->EmailBody .= $this->EmailMessage;
if(count($this->EmailFiles) > 0){
for($i=0;$i<count($this->EmailFiles);$i++){
$rfile = $this->EmailFiles[$i];
if(!($fd = fopen($rfile, "r"))){
$this->EmailErrors .= "Failed to open ".$this->EmailFiles[$i]."!\n";
$this->EmailError = 1;
continue(1);
}
$text = chunk_split(base64_encode(fread($fd, filesize($rfile))));
$this->EmailBody .= "\n--".$un_bound."\n";
$this->EmailBody .= "Content-Type: application/octet-stream;\n";
$this->EmailBody .= "Content-Transfer-Encoding: base64\n";
$this->EmailBody .= "Content-Type: application/zip; name=\"".basename($rfile)."\"\n";
$this->EmailBody .= "Content-Disposition: attachment; filename = ".basename($rfile)."\n\n";
$this->EmailBody .= $text;
}
}
$this->EmailBody .= "\n--".$un_bound."--\n";
}
function SendEmail()
{
for($i=0; $i < count($this->Emails);$i++){
$this->EmailTo = $this->Emails[$i];
if(!mail($this->EmailTo, $this->EmailSubject, $this->EmailBody, $this->Headers)){
$sent = FALSE;
$this->EmailErrors .='Failed to send mail to '.$this->EmailTo.'\n';
$this->EmailError = 1;
}else{
$sent = TRUE;
}
}
return $sent;
}
}
?>