Email in PHP does not work

Asked

Viewed 230 times

1

It does not give any error, just does not get the message. Sending normally via a Webmail will normal, follow the form:

<form method="post" action="sendMail.php" id="formMail">
        Assunto: <input name="assunto" type="text" class="txtMail" placeholder=" O assunto do seu email aqui"/><br />
        Mensagem:<br />
  <textarea name="comment" rows="12" cols="50" placeholder=" Sua mensagem aqui"></textarea><br />
  <input type="submit" value="Enviar" /><br><br>
  </form>

and the code in PHP:

<?php 
    if(isset($_POST['assunto'], $_POST['mensagem'])){
        $para = "[email protected]";
        $assunto = $_POST['assunto'];
        $msg = $_POST['message'];

        mail($para, $assunto, $msg);
    }
?>

Another question, is there any way to send by the way mail(); the email message from the person who is sending me?

1 answer

5


Buddy, there’s a mistake here:

$msg = $_POST['message'];

The tag’s "name" attribute is "comment", not "message". Leave the variable like this:

$msg = $_POST['comment'];
  • Wow... thanks for the alert, sorry for the immense lack of attention...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.