Send PHP emails, GoDaddy Server

1

Dear, recently I bought a domain and hosting in GoDaddy , all right until you create my form with my. php file so that the emails arrive to my email, so I find that nothing comes to me, here my code

PHP

    <?php
$nombre = $_POST['nombre'];
$mail = $_POST['email'];
$empresa = $_POST['mensaje'];

$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$mensaje = "Este mensaje fue enviado por " . $nombre . ",\r\n";
$mensaje .= "Su e-mail es: " . $mail . " \r\n";
$mensaje .= "Mensaje: " . $_POST['mensaje'] . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time());

$para = '***@****.com';
$asunto = 'Mensaje de mi sitio web';

mail($para, $asunto, utf8_decode($mensaje), $header);

header("Location:index.html");
?>

Here my form

<form action="" method="post" role="form" class="contactForm"  action="process.php">
                <div class="col-md-6 padding-right-zero">
                    <div class="form-group">
                        <input type="text" name="name" class="form-control" id="name" placeholder="Su Nombre" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
                        <div class="validation"></div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <input type="email" class="form-control" name="email" id="email" placeholder="Su Correo" data-rule="email" data-msg="Please enter a valid email" />
                        <div class="validation"></div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="form-group">
                        <input type="text" class="form-control" name="subject" id="subject" placeholder="Asunto" data-rule="minlen:4" data-msg="Please enter at least 8 chars of subject" />
                        <div class="validation"></div>
                    </div>
                </div>
                <div class="col-md-12">
                  <div class="form-group">
                        <textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Mensaje"></textarea>
                        <div class="validation"></div>
                    </div>
                  <button type="submit" class="btn btn-primary btn-submit">ENVIAR</button>
                </div>
            </form>

And well I do not realize if my code is wrong the truth seems to me that it is correct apart from that I used it once on another page but on another server and if it worked, someone knows if GoDaddy has some configuration more than Do not know, I'm pretty new in all this. I appreciate all help thanks

    
asked by Bruno Sosa Fast Tag 28.07.2017 в 20:34
source

1 answer

1

The mail () function returns true if the email was sent or false if it could not be sent.

if(mail(/* parámetros /*)) {
    // El correo fue enviado correctamente
} else {
    // No se pudo enviar el correo
    // Es necesario contactar con el soporte de tu hosting
}

Generally, when the mail is sent and you do not receive it in services such as gmail, hotmail, yahoo, etc., it is because the headers are insufficient and it will be marked as SPAM; In some cases you will get to the tray of unwanted items, but you may also never receive it.

Suggestion: Use a library like PHPMailer that generates very complete headings and reduces the possibility to a minimum that the emails are considered as SPAM.

    
answered by 29.07.2017 / 19:41
source