[*] исправлен метод отправки письма администратору
This commit is contained in:
1 parent
ea3bd2bd0e
commit
b2835e0954
3 files changed
+22
-112
No files matched your search
@@ -218,89 +218,4 @@ class CMail {
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправка с использованием встроенных стилей
|
||||
*/
|
||||
public function sendDefault()
|
||||
{
|
||||
if (empty($this->toEmail)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// От кого
|
||||
$from = (empty($this->fromName)) ? $this->fromEmail : '=?UTF-8?B?' . base64_encode($this->fromName) . '?= <' . $this->fromEmail . '>';
|
||||
|
||||
// Кому
|
||||
$array_to = array();
|
||||
foreach (explode(',', $this->toEmail) as $row) {
|
||||
$row = trim($row);
|
||||
if (!empty($row)) {
|
||||
$array_to[] = (empty($this->toName)) ? $row : '=?UTF-8?B?' . base64_encode($this->toName) . '?= <' . $row . '>';
|
||||
}
|
||||
}
|
||||
|
||||
// Тема письма
|
||||
$subject = (empty($this->subject)) ? 'No subject' : $this->subject;
|
||||
|
||||
// Текст письма
|
||||
$body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
' . $this->body . '
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
// Добавление стилей к тегам
|
||||
$body = $this->addHtmlStyle($body);
|
||||
|
||||
$boundary = md5(uniqid(time()));
|
||||
|
||||
// Заголовок письма
|
||||
$headers = array(
|
||||
'Content-Type: multipart/mixed; boundary="' . $boundary . '"',
|
||||
'Content-Transfer-Encoding: 7bit',
|
||||
'MIME-Version: 1.0',
|
||||
'From: ' . $from,
|
||||
'Date: ' . date('r')
|
||||
);
|
||||
|
||||
// Тело письма
|
||||
$message = array(
|
||||
'--' . $boundary,
|
||||
'Content-Type: text/html; charset=UTF-8',
|
||||
'Content-Transfer-Encoding: base64',
|
||||
'',
|
||||
chunk_split(base64_encode($body))
|
||||
);
|
||||
|
||||
if (!empty($this->_files)) {
|
||||
foreach ($this->_files as $row) {
|
||||
$message = array_merge($message, array('', '--' . $boundary), $row);
|
||||
}
|
||||
}
|
||||
|
||||
$message[] = '';
|
||||
$message[] = '--' . $boundary . '--';
|
||||
$res = array();
|
||||
|
||||
foreach ($array_to as $to) {
|
||||
// Дамп письма в файл
|
||||
if ($this->dump == true) {
|
||||
if (empty($this->dumpPath)) {
|
||||
$this->dumpPath = dirname(__FILE__) . '/uploads';
|
||||
}
|
||||
|
||||
$dump = array_merge($headers, array('To: ' . $to, 'Subject: ' . $subject, ''), $message);
|
||||
$file = $this->safeFile($this->dumpPath . '/' . date('Y-m-d_H-i-s') . '.eml');
|
||||
file_put_contents($file, implode("\r\n", $dump));
|
||||
}
|
||||
$res[] = mb_send_mail($to, $subject, implode("\r\n", $message), implode("\r\n", $headers));
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user