O
O
Oleg_xex2017-09-20 20:30:33
PHP
Oleg_xex, 2017-09-20 20:30:33

Php does not send letters to the mail. What should I do?

I have a contact form on my site, here is the code -

<form id="contactform" name="contact" method="post" action="page.php">

<div class="row">
<label for="name">Имя,Фамилия <span class="req"></span></label>
<input type="text" name="name" id="name" class="txt" tabindex="1" placeholder="" required>
</div>

<div class="row">
<label for="email">E-mail <span class="req"></span></label>
<input type="email" name="email" id="email" class="txt" tabindex="2" placeholder="" required>
</div>

<div class="row">
<label for="phone">Номер телефона <span class="req"></span></label>
<input type="phone" name="phone" id="phone" class="txt" tabindex="2" placeholder=" " required>
</div>

<div class="row">
<label for="subject">Марка,модель и год выпуска авто <span class="req"></span></label>
<input type="text" name="subject" id="subject" class="txt" tabindex="4" placeholder="" required>
</div>

<div class="row">
<label for="message">Гос. номер авто <span class="req"></span></label>
<input type="text" name="message" id="message" class="txt" tabindex="3" placeholder="" required>
</div>


<div class="center">
<input type="submit" id="submitbtn" name="s" tabindex="5" value="Отправить анкету">
</div>
</form>


here is the php code -
<?php
header('Content-type: text/html; charset=utf-8');
header('Refresh: 0.5; url="index.html"');
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];




if (mail("[email protected]", "Заявка с сайта", "Имя:".$name ,". E-mail: ".$email , "Телефон:".$phone ,". Авто: ".$subject ,". Гос.номер авто: ".$message ,"  \r\n"))
 {     echo "<h3>Cообщение успешно отправлено. </h3>"; 
} else { 
    echo "При отправке сообщения возникли ошибки ";
}

?>


Letters are not sent and always writes "There were errors while sending the message"
What's wrong?
Perhaps something with hosting? Hosting TheHost
Account supports php.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2017-09-20
@BorisKorobkov

You are passing too many parameters to mail and in the wrong format.
ru2.php.net/manual/ru/function.mail.php

E
Egor Peregudov, 2017-09-20
@Stalk-p

Replace line
on the

if (mail("[email protected]", "Заявка с сайта", "Имя:".$name.". E-mail: ".$email. "Телефон:".$phone.". Авто: ".$subject.". Гос.номер авто: ".$message."))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question