Contact Form does not send a message - UOL Host

Asked

Viewed 878 times

4

The form even picks up the data after clicking on Ubmit, sends the user to a thank you page but the message does not reach the destination, which is my email.

HTML:

<section id="contato">                      
                <h1>CONTATO</h1>    
                    <div id="caixas-texto">
                        <form action="contato.php" method="post">
                            <label for="nome">Nome:</label> <br>
                            <input type="text" id="nome" name="nome" size="48" maxlength="48"><br><br>
                            <label for="fone">Telefone:</label> <br>
                            <input type="text" id="fone" name="fone" size="11" maxlength="11"><br><br>
                            <label for="email">Email:</label> <br>
                            <input type="text" id="email" name="email" size="48" maxlength="48"><br><br>
                            <label for="msg">Mensagem:</label> <br>
                            <textarea id="msg" name="msg" rows="5" cols="50"maxlength="200"
                            placeholder="Mande sua mensagem! Vamos trabalhar!"></textarea>

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

PHP

        <?php
$para= "[email protected]";
$assunto= "Contato pelo site";
$nome= $_REQUEST['nome'];
$fone= $_REQUEST['fone'];
$email= $_REQUEST['email'];
$mensagem= $_REQUEST['msg'];
    $corpo= "<strong> Mensagem de Contato</strong><br><br>";
    $corpo .= "<br><strong> Nome: </strong> $nome";
    $corpo .= "<br><strong> Telefone: </strong> $fone";
    $corpo .= "<br><strong> Email: </strong> $email";
    $corpo .= "<br><strong> Mensagem: </strong> $mensagem"; 
    $header= "Content-Type: text/html; charset= utf-8\n";
    $header .="From: $email Reply-to: $email\n";    
mail($para,$email,$assunto,$corpo,$header);
header("location:retorno-email.html?envio=enviado");
?>

My site is on a UOL server, I don’t understand what might be going on.

  • 4
  • 1

    I recommend using some mail sending server with SMTP configured right. The UOL website itself has an article on this subject: https://uolhost.uol.com.br/faq/v2/hosting/como-enviarmensagens-com-php-por-authenticationo-smtp.html#rmcl In doing as you have shown, the email may take a long time to arrive, or even arrive because it is considered spam from an unreliable sender. Basically speaking, I recommend you configure the UOL email server to make these submissions for you.

  • Thank you so much for your solution. It helped me solve the problem. At https://github.com/PHPMailer/PHPMailer/tree/5.2-stable. I was able to find a version with the files I needed to make my form work.

1 answer

3


<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?> 

You must change the order too.

  • 1

    Thank you so much for your help, I’ve already made my form work!

Browser other questions tagged

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