Error sending php message

Asked

Viewed 71 times

0

Good night created a test file for me to learn how to send a form to an email through php and when I run by easyPHP Devserver 16.1.1 and press the send button the page is blank

and it doesn’t 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 believe that the place that may be giving problem would be the file send.php

$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 "";

}

Could someone help me... thank you.

  • what error? only appears the message Voce posted above? look at my new reply

  • Yes... when I click the send button it appears a snippet of php code

1 answer

1


After chatting with Nathan on Chat, I discovered that the issue is that he was trying to send the email from his local machine without setting up any email server.

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

  • So friend had fixed that part, when I run it appears this part '; $email = mail($destination, $subject, $headers); if($enviar email) { $mgm = "Email sent successfully"; } Else { $mgm = "error sending"; echo ""; } ?>... had edited my question, give a look there, thanks for trying

  • You have posted the line that is wrong. Which error message?

  • I changed the answer, see if it resolves

  • Didn’t work buddy... I changed my question above indicating where I think the error may be.

  • look at the change again. still distrustful of concatenation

  • I’ll try just this once, see the code now. if it doesn’t I give up. I’m waiting for the answer

  • I put in a way that when I click on the button send the page is blank... I will change the question there of a look.

  • Ready @Italo Rodrigo

  • the page is blank because your echo was wrong, I corrected it in my reply

  • is changed nothing not... but thanks for you are here trying to help me.

  • does not show anything else? Voce made the change in echo?

  • I put as you said and still the page is blank when I send

Show 8 more comments

Browser other questions tagged

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