Ошибка такова: При регистрации или смене пароля приходит письмо на е-маил, с соответствующим названием письма, то есть все верно определяется какое письмо должно прийти, НоО ни в одном письме нет тела, то есть приходит пустое письмо
Вот код класса:
<?php
/**
* Класс для работы с почтой
*/
if( ! defined( 'LM' ) ) die('Попытка взлома?');
class mail {
var $errstr;
var $headers;
var $textbody;
var $htmlbody;
var $attachments;
var $boundary;
// Default constructor, sets up default header and boundary.
function mail() {
$this->attachments = array();
$this->boundary = '_lightmon_mail_boundary_';
$this->headers = array(
'From' => 'LightMon Mail Class <default@lightmon.ru>',
'MIME-Version' => '1.0',
'X-Priority' => '5',
'Content-Type' => "multipart/mixed; boundary=\"$this->boundary\""
);
$this->bodytext("");
}
// For debugging purposes you can display the body you are about
// to send.
function get_body() {
$retval = $textbody;
$retval .= $htmlbody;
foreach($this->attachments as $tblck)
$retval .= $tblck;
return $retval;
}
// Convert the values in the header array into the correct format.
function get_header() {
$retval = "";
foreach($this->headers as $key => $value)
$retval .= "$key: $value\n";
return $retval;
}
// Add your own header entry or modify a header.
function set_header($name, $value) {
$this->headers[$name] = $value;
}
// Attach a file to the message.
function attachfile($file, $type = "application/octetstream") {
if(!($fd = fopen($file, "r"))) {
$this->errstr = "Error opening $file for reading.";
return 0;
}
$_buf = fread($fd, filesize($file));
fclose($fd);
$fname = $file;
for($x = strlen($file); $x > 0; $x--)
if($file[$x] == "/")
$fname = substr($file, $x, strlen($file) - $x);
// Convert to base64 becuase mail attachments are not binary safe.
$_buf = chunk_split(base64_encode($_buf));
$this->attachments[$file] = "\n--" . $this->boundary . "\n";
$this->attachments[$file] .= "Content-Type: $type; name=\"$fname\"\n";
$this->attachments[$file] .= "Content-Transfer-Encoding: base64\n";
$this->attachments[$file] .= "Content-Disposition: attachment; " .
"filename=\"$fname\"\n\n";
$this->attachments[$file] .= $_buf;
return 1;
}
function bodytext($text) {
// Set the content type to text/plain for the text message.
// 7bit encoding is simple ASCII characters, this is default.
$this->textbody = "\n--" . $this->boundary . "\n";
$this->textbody .= "Content-Type: text/plain\n";
$this->textbody .= "Content-Transfer-Encoding: 7bit\n\n";
$this->textbody .= $text;
}
function htmltext($text) {
// Set the content type to text/html for the html message.
// Also uses 7bit encoding.
$this->htmlbody = "\n--" . $this->boundary . "\n";
$this->htmlbody .= "Content-Type: text/html\n";
$this->htmlbody .= "Content-Transfer-Encoding: 7bit\n\n";
$this->htmlbody .= $text;
}
function clear_bodytext() { $this->textbody = ""; }
function clear_htmltext() { $this->htmlbody = ""; }
function get_error() { return $this->errstr; }
// Send the headers and body using php's built in mail.
function sendmail($to = "root@localhost", $subject = "Default Subject") {
if(isset($this->textbody)) $_body .= $this->textbody;
if(isset($this->htmlbody)) $_body .= $this->htmlbody;
foreach($this->attachments as $tblck)
$_body .= $tblck;
$_body .= "\n--$this->boundary--";
if(@mail($to, $subject, $_body, $this->get_header())) return true;
else return false;
}
}
?>
а вот само тело письма, которое должна отправляться:
$htmltext = 'Для завершения регистрации на сервисе '.$_SERVER['HTTP_HOST'].' (<a href="'.$_SERVER['HTTP_HOST'].'/">http://'.$_SERVER['HTTP_HOST'].'/</a>) перейдите пожалуйста по ссылке:<br><br> <a href="' . $YourRegLink . '">' . $YourRegLink . '</a><br><br>Код подтверждения: '.$randcode.'<br>Ссылка: <a href="'.(($conf['rewrite']=='on') ? 'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']),'/\\').'/validate-user.html' : 'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']),'/\\').'/index.php?do=user&validate').'">'.(($conf['rewrite']=='on') ? 'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']),'/\\').'/validate-user.html' : 'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']),'/\\').'/index.php?do=user&validate').'</a>';
$htmltext = $htmltext . '<br><br>';
$htmltext = $htmltext . 'С уважением,<br>Администрация сайта <b><a href="http://'.$_SERVER['HTTP_HOST'].'/">'.$_SERVER['HTTP_HOST'].'</a></b>';
$main->mail->set_header('From', $conf['support_mail']);
$main->mail->htmltext($htmltext);
if ($main->mail->sendmail($mail, 'Активация аккаунта') && $conf['allow_registration'] == 'yes') {
$contents = '<b><center><b>'.$lang['user_text11'].'</b></center></b>';
} else {
$contents = '<b><center><b>'.$lang['user_text45'].'<br><a href="'.$YourRegLink.'">'.$lang['user_text46'].'</a>.</b></center></b>';
}
}
}
}