Answer the question
In order to leave comments, you need to log in
How to send a PHP email?
There is a feedback form. The task is to send a message to your mail. Like wrote a script, but the letter is not sent.
<?php
$name = htmlspecialchars($_POST["name"]);
$contacts = htmlspecialchars($_POST["contacts"]);
$message = htmlspecialchars($_POST["message"]);
$address = "[email protected]";
$sub = "Сообщение с сайта";
$mes = "Сообщение с сайта.\n
Имя отправителя: $name
Контакты отправителя: $contacts
Текст сообщения:
$message";
if (mail($address, $sub, $mes)) {
echo '<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>Письмо отправлено, через 5 секунд вы вернетесь на страницу XXX</body>';}
else {
echo '<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>Письмо не отправлено, через 5 секунд вы вернетесь на страницу YYY</body>';}
?>
Answer the question
In order to leave comments, you need to log in
If you don’t want to play around, test, but for work, take PHPMailer .
The mail() function looks simple, but for it to work correctly, the server must be properly configured. And this is rather rare.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question