Перейти к содержанию

▍Отправка писем через sendmail в PHP

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

или

<?php

function mail_utf8($to, $from, $subject, $message)
{
    $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';

    $headers  = "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-type: text/plain; charset=utf-8\r\n";
    $headers .= "From: $from\r\n";

    return mail($to, $subject, $message, $headers);
}

//Пример использования:

mail_utf8('[email protected]', '[email protected]', 'Заголовок сообщения', 'Текст сообщения');

?>
К началу