40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
|
<?php
|
||
|
function send_mime_mail($name_from, // имя отправителя
|
||
|
|
||
|
$email_from, // email отправителя
|
||
|
|
||
|
$name_to, // имя получателя
|
||
|
|
||
|
$email_to, // email получателя
|
||
|
|
||
|
$data_charset, // кодировка переданных данных
|
||
|
|
||
|
$send_charset, // кодировка письма
|
||
|
|
||
|
$subject, // тема письма
|
||
|
|
||
|
$body // текст письма
|
||
|
|
||
|
) {
|
||
|
|
||
|
|
||
|
$to = mime_header_encode($name_to, $data_charset, $send_charset)
|
||
|
. ' <' . $email_to . '>';
|
||
|
$subject = mime_header_encode($subject, $data_charset, $send_charset);
|
||
|
$from = mime_header_encode($name_from, $data_charset, $send_charset)
|
||
|
.' <' . $email_from . '>';
|
||
|
if($data_charset != $send_charset) {
|
||
|
$body = iconv($data_charset, $send_charset, $body);
|
||
|
}
|
||
|
$headers = "From: $from\r\n";
|
||
|
$headers .= "Content-type: text/html; charset=$send_charset\r\n";
|
||
|
|
||
|
mail($to, $subject, $body, $headers);
|
||
|
}
|
||
|
function mime_header_encode($str, $data_charset, $send_charset) {
|
||
|
if($data_charset != $send_charset) {
|
||
|
$str = iconv($data_charset, $send_charset, $str);
|
||
|
}
|
||
|
return '=?' . $send_charset . '?B?' . base64_encode($str) . '?=';
|
||
|
}
|
||
|
?>
|