Пример использования функции mail() в PHP Example mail()

Пример использования функции для отправки писем на почтовый ящик:

    $to      = 'mailto@example.com';
    $subject = "This is subject";
    
    $message = "<b>This is HTML message.</b>";
    $message .= "<h1>This is headline.</h1>";
    
    $header = "From: mailsender@example.com \r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-type: text/html\r\n";
    
    $retval = mail ($to,$subject,$message,$header);
    
    if( $retval == true ) {
    echo "Message sent successfully...";
    }else {
    echo "Message could not be sent...";
    }

в переменную $to — подставляем почту получателя

а в переменной $header — пишем почту отправителя

Вам также может понравиться

About the Author: Vladimir Kusakin

Hi. I am web developer. For the past 9 years, I've been developing applications for the web using mostly PHP and Python. About me

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *