0
I’m with a problem in the contact form of my site, I believe it is configured correctly but it is not sending the email through the form, I would like to know if it is error in the code, it is the only thing that is missing to finish.
The code PHP
is like this:
<?php
$name = @trim(stripslashes($_POST['name']));
$from = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$to = "[email protected]";//replace with your email
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);
die;
?>
And the html
thus:
<form id="main-contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="form-group">
<input type="text" name="name" class="form-control" required="required" placeholder="Nome">
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" required="required" placeholder="Email">
</div>
<div class="form-group">
<textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Sua Mensagem"></textarea>
</div>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-submit" value="Enviar">
</div>
</form>
This PHP code is inside the file
sendemail.php
? and by the way the name is eithersendmail.php
(withoute
)? Another thing, I don’t see the fieldsubject
...– Sergio
that
sendemail.php
is the one in both– João Victor Gomes Moreira
@Sergio you know what can be?
– João Victor Gomes Moreira
In your HTML you do not have the "Subject" field and without this information the PHP mail function does not work!
– Igor Mello
and how it could work @igormello ?
– João Victor Gomes Moreira