Error sending message in php [duplicate]

0

Good night I created a test file for me to learn how to send a form to an email via php and when I run it through easyPHP Devserver 16.1.1 and hit the submit button the page goes blank

And it does not arrive in my email ... what would be the problem, I'm putting the files below

My file -

index.html:

  <html>

<head>
    <title>Enviar email em php</title>

    <link rel="stylesheet" type="text/css" href="estilo.css">
</head>


<body>
    <div id="contato_form">
        <form action="enviar.php" name="form_contato" method="post">
            <p class="titulo">Fomulario <small class="asteristico">* Campos obrigatorios</small></p>

            <p>Nome*:
                <br/>
                <input type="text" name="nome" />

            </p>


            <p>Email*:
                <br/>
                <input type="email" name="email" />

            </p>


            <p>Telefone*:
                <br/>
                <input type="text" name="telefone" />

            </p>

            <br />


            <span>Opcoes</span>
            <br/>

            <select name="escolhas">
                <option value="Opcao 1">Opcao 1</option>

                <option value="Opcao 2">Opcao 2</option>

            </select>

            <br/>

            <p>Mensagem:</p>
            <br />

            <textarea name="msg"></textarea>


            <br />
            <br />
            <br />
            <br />

            <input type="reset" value="Limpar" />

            <input type="submit" value="Enviar" />
        </form>
    </div>

</body>
</html>

send.php -

<? php
    //Variaveis
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$opcoes = $_POST['escolhas'];
$mensagem = $_POST['msg'];
$data_envio = date('d/m/Y');
$hora_envio = date('H:I:S');


// Enviar

// email para quem sera enviado o formulario
$emailsenviar = "[email protected]";
$destino = $emailsenviar;
$assunto = "contato teste";


// e necessario indicar que o formato do email e html

$headers = 'MIME-Version: 1.0' . '\r\n' . 'Content-type: text/html; charset=iso-8859-1' . '\r\n' . 'From: $nome';

$enviaremail = mail($destino, $assunto, $headers);
if($enviaremail) {
    $mgm = "Email enviado com sucesso";

} else {
    $mgm = "error ao enviar";
    echo "";

}


    ?>

I think the location that might be giving trouble would be in the send.php file

$headers = 'MIME-Version: 1.0' . '\r\n' . 'Content-type: text/html; charset=iso-8859-1' . '\r\n' . 'From: $nome';

$enviaremail = mail($destino, $assunto, $headers);
if($enviaremail) {
    $mgm = "Email enviado com sucesso";

} else {
    $mgm = "error ao enviar";
    echo "";

}

Someone could help me ... thanks.

    
asked by anonymous 20.12.2016 / 02:54

1 answer

1

After talking to Nathan in Chat, I discovered that the point was that he was trying to send email from his local machine without setting up any email server.

So I recommended that he look for a more specific tutorial and recommended that he study for that other topic: How to send localhost email using the PHP mail function?

    
20.12.2016 / 03:01