3
Based on the code below, used for sending email:
<?php
$from = $_POST['email'];
$to = '[email protected]';
$subject = $_POST['subject'];
$message = $_POST['content'];
$headers = 'From: ' . $from . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=utf-8';
if(mail($to, $subject, $message, $headers))
echo "Email sent";
else
echo "Email sending failed";
?>
And the form:
<form action="/mail/send-mail.php" method="post">
<div class="form-group">
<input type="text" class="form-control" name="name" id="contact-name" placeholder="Nome">
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" id="contact-email" placeholder="Email">
</div>
<div class="form-group">
<input type="text" class="form-control" name="subject" id="contact-subject" placeholder="Assunto">
</div>
<div class="form-group">
<textarea class="form-control" name="content" id="contact-content" placeholder="Mensagem" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-default text-uppercase" id="contactButton"> Enviar</button>
</form>
The return is always false.
is using some framework?
– Erlon Charles
am not......
– Igor Ronner
The PHP log says something?
– Vinícius Gobbo A. de Oliveira
because the action of your form is like this
action="@routes.Assets.at("send-mail.php")"
?– Erlon Charles
send-mail.php
is the name of your file that will perform php uploading?– Erlon Charles
Edith. Yes Erlon Charles!
– Igor Ronner
Igor, do you use windows? If so, to use the function
mail
, you need an SMTP service installed. I recommend using Phpmailer for sending emails. Already comes with smtp support, no need to install any service. (https://github.com/PHPMailer/PHPMailer)– Rafael Withoeft
Nothing Vinicius! Only Return false;
– Igor Ronner
Rafael, I use Mac OS.
– Igor Ronner
Take a look at this article then: http://jasper.tandy.is/blogging/php-mail-and-osx-leopard/
– Rafael Withoeft
Good morning, I wonder if any of the answers helped you, if not please comment on what you think is missing.
– Guilherme Nascimento