Problem PHP web form with Godaddy server

0

Make a PHP form for a web page, the problem is that when I add the address of my domain ".com" it never comes to my inbox. I have done tests with my gmail and outlook account, even with a ".com.mx" account and with these I do not present the same problems, my mail accounts and hosting are in Godaddy. What is the error within my code? I hope you can help me. thanks

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>IKTUM</title>
<link href="css/style1.css" rel="stylesheet">
<script type="text/javascript">
    function Redireccionar(){
        window.location='index.php';
    }
    setTimeout('Redireccionar()', 1000);
</script>
</head>
<body>
<div class="container">

<?php 
if(isset($_POST['nombre'])&&($_POST['correo']!='')
&&($_POST['mensaje']!='')){
            $nombre = $_POST['nombre'];
            $correo = $_POST['correo'];
            $mensaje = $_POST['mensaje'];
            //direción de mi correo
            $para = "[email protected]";
            //Contenido del mensaje
            $titulo = "Contacto ";
            $contenido = '<html>
                            <head>
                                <title>' . $titulo . '</title>
                            </head>
                            <body>
                                <p>El visitante <strong>' . $nombre .
'</strong> te ha enviado el siguiente mensaje:</p>
                                <p>Mensaje: ' . $mensaje . ' <br><br> Puedes 
ponerte en contacto al email: ' . $correo . '</p>
                                <p>Este mensaje ha sido generado desde la 
página de iktum.com</p> 
                            </body>
                        </html>';
            $encabezado = "MINE-Version: 1.0\r\n";
            $encabezado .= "Content-type: text/html; charset=UTF-8\r\n";
            $encabezado .= "From: "Sitio web" \r\n";
            $encabezado .= "Reply-To: \r\n";

            $envio = mail($para,$titulo,$contenido,$encabezado);


            if($envio == true){
            }
            else{
                echo "<h1>Se ha presentado un error en el envío del  

email</h1>";
            }


        }
        else{
            echo "<h1>Se ha presentado un error, completa los campos del    
formulario</h1>";
        }
    ?>

</div>
</body>
</html>
    
asked by braunche 30.06.2016 в 00:42
source

3 answers

1

I understand that the email is sent, and you say that you have received it in other mail services correctly? Then it might not be your code. I do not know if you have the mail service properly configured. Have you sent mail from external services to the account you want to use? Did they arrive?

In any case, for the tests, you must simplify. We must discard possible errors ...

First you must check that messages arrive at the account. Use an external service to send you an email. It works. You have to check that it comes from what you are developing. You must remove the optional parameters of mail (you must use only the first 3). Then send a simple string, such as "test" from a script that only sends. If it arrives, you can add optional parameters, format to the message, etc.

When something does not work, you have to go from less to more.

    
answered by 30.10.2016 в 09:38
0

First, I see some problems in your code:

$encabezado = "MINE-Version: 1.0\r\n"; #Intercambia MINE por MIME
$encabezado = "MIME-Version: 1.0\r\n"; #Correcto

And you could save a few lines of code by changing the send section with

        if(mail($para,$titulo,$contenido,$encabezado)) {
            #En caso de que el correo se envíe
        }else {
            #Error
        }

In the same way, in my experience, GoDaddy has always had problems when sending PHP forms, problems such as not being able to send emails or marked as SPAM, to avoid them, I recommend using and configuring PHPMailer , is a PHP-based, object-oriented email library that is very easy to use, in the link you will see several very useful examples.

    
answered by 09.09.2018 в 04:19
0

Maybe it's the mime, change the MINE for MIME;

 $encabezado = "MIME-Version: 1.0\r\n";

Also escapes the quotes or inserts by single quote ' :

 $encabezado .= "From: \"Sitio web\" \r\n";
    
answered by 30.06.2016 в 00:45