Answer the question
In order to leave comments, you need to log in
How to send mail from PHP?
Good day! I am now implementing a simple HTML form on the site that collects data and sends it by letter to a specific address. Wrote the following code:
$to = '[email protected]';
$subject = 'Тема письма';
$from = ' [email protected]>';
$headers = "From: $from\r\n";
$headers .= "Reply-To: $from\r\n";
$headers .= "Return-Path: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "X-Mailer: PHP" . phpversion() . "\r\n";
$message =
"<html>
<body>Текст письма</body>
</html>";
mail($to, $subject, $message, $headers);
Answer the question
In order to leave comments, you need to log in
I fought with mail() for a long time and eventually switched to PHPMailer+SMTP. It works more stable. You can use Yandex SMTP if Yandex mail service for domain is used for the domain from which the message is being sent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question