I
I
Ivan Smirnov2017-05-26 13:15:57
PHP
Ivan Smirnov, 2017-05-26 13:15:57

How to write a script for sending a letter in php with reg.ru hosting?

There is a working script and hosting Reg.ru which has [email protected] mail, how to rewrite my code so that the letter does not just come under the name "[email protected]", but that it really comes from this address, I really look forward to hearing , thank you very much in advance!

<!DOCTYPE html>
<html>
   
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="Refresh" content="2; URL=http://test.ru">
        <title>Форма обратной связи Test</title> 
    </head>
    
<body>

<?php 

// Почта, на которую приходит письмо
$sendto   = "[email protected]"; // почта, на которую приходит письмо

// Записываем данные из полей ввода в переменные
$username = $_POST['name'];
$usertel = $_POST['telephone'];
$usermail = $_POST['email'];

// Тема письма
$subject  = "Пришлите прайс";

// Дополнительные заголовки
$headers .= "From: Отправитель <[email protected]>\r\n";
$headers .= "Content-type: text/html; charset=utf-8 \r\n";

// Формирование тела письма
$msg  = "<html><body style='font-family: Arial, sans-serif; font-size: 2vw;'>";
$msg .= "<h1 style='font-weight: bold;'>Данные клиента:</h1>\r\n";
$msg .= "<p><strong>Имя:</strong> ".$username."</p>\r\n";
$msg .= "<p><strong>Почта:</strong> ".$usermail."</p>\r\n";
$msg .= "<p><strong>Телефон:</strong> ".$usertel."</p>\r\n";
$msg .= "</body></html>";

// отправка сообщения
if(@mail($sendto, $subject, $msg, $headers)) {
  echo "<center><span style='color: green;'><h1>Сообщение успешно отправленно</h1><br><h2>Мы свяжемся с вами в ближайшее время! </h2></span></center>";
} else {
  echo "<center><img src='img/ne-otprevleno.png'></center>";
}

?>

</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4iloveg, 2017-05-26
@4iloveg

php.net/manual/ru/function.mail.php
See how additional headers are specified there, try the same

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question