-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* The “sendMail” method was slightly changed to eliminate errors in P…
…HP 5.4-5.6 during headers validation: - All double “\r\n” and singe “\r\n” were replaced with single PHP_EOL. - Leading or trailing PHP_EOL's are now trimmed in email content.
- Loading branch information
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1047,14 +1047,14 @@ public static function sendMail($to, $text, $from = '[email protected]', $sub | |
//Конвертируем тему в base64 | ||
$subject = "=?UTF-8?B?".base64_encode($subject)."?="; | ||
//Заголовки сообщения | ||
$headers = "From: $from\r\nMIME-Version: 1.0\r\n"; | ||
$headers = "From: ".$from.PHP_EOL."MIME-Version: 1.0".PHP_EOL; | ||
|
||
//Разделитель блоков в сообщении | ||
$bound = 'bound'.md5(time()); | ||
$multipart = "Content-Type: multipart/mixed; boundary = \"".$bound."\"\r\n\r\n--".$bound; | ||
$multipart = "Content-Type: multipart/mixed; boundary = \"".$bound."\"".PHP_EOL."--".$bound.PHP_EOL; | ||
|
||
//Добавлеям текст в сообщения | ||
$multipart .= "\r\nContent-Type: text/html; charset=UTF-8 \r\n\r\n".$text."\r\n\r\n--".$bound; | ||
$multipart .= "Content-Type: text/html; charset=UTF-8 ".PHP_EOL.trim($text, PHP_EOL).PHP_EOL."--".$bound; | ||
|
||
if(!empty($fileInputName)){ | ||
$attachFiles = array(); | ||
|
@@ -1088,16 +1088,16 @@ public static function sendMail($to, $text, $from = '[email protected]', $sub | |
//Перебираем присоединяемые файлы | ||
if(!empty($attachFiles)){ | ||
foreach($attachFiles as $name => $value){ | ||
$multipart .= "\r\n". | ||
'Content-Type: application/octet-stream; name = "=?UTF-8?B?'.base64_encode($name)."?=\"\r\n". | ||
"Content-Transfer-Encoding: base64\r\n\r\n". | ||
base64_encode($value)."\r\n\r\n--".$bound; | ||
$multipart .= PHP_EOL. | ||
'Content-Type: application/octet-stream; name = "=?UTF-8?B?'.base64_encode($name)."?=\"".PHP_EOL. | ||
"Content-Transfer-Encoding: base64".PHP_EOL. | ||
base64_encode($value).PHP_EOL."--".$bound; | ||
} | ||
} | ||
} | ||
|
||
//Добавляем разделитель окончания сообщения | ||
$headers .= $multipart."--\r\n"; | ||
$headers .= $multipart."--".PHP_EOL; | ||
|
||
$result = array(); | ||
|
||
|