Как отправить письмо с php with mail()
Такая форма:
<form action="main.php" method="POST">
<input type="text" name="user_phone" placeholder="" />
<input type="submit" value="Оставить заявку" />
</form>
и такой main.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
if (isset($_POST["user_phone"])) {
$user_phone = $_POST["user_phone"];
echo "user phone is set";
echo "<br />";
}
else
exit();
$message = "$user_phone - user phone";
mail('[email protected]', 'My Subject', $message);
echo "ready";
На странице вывод такой:
user phone is set
ready
Но письмо не приходит на почту. Не могу понять в чем дело, может вы сможете найти ошибку
Ответы (1 шт):
Автор решения: Vadim
→ Ссылка
Если так попробовать?
$mailheaders = "Content-Type: text/plain; charset=utf-8\r\n";
$mailheaders .= "From: [email protected]\r\n";
mail('[email protected]', 'My Subject', $message, $mailheaders);