Php smtp error godaddy

0

I am trying to send a form in PHP to send it through the Godaddy server, but when I send it I get the error

<?php
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$compania = $_POST['compania'];
$telefono = $_POST['telefono'];
$pais = $_POST['pais'];
$videoconferencia = $_POST['videoconferencia'];




if ($nombre==''||
$email==''){

echo "<script>alert('Los campos marcados con * son obligatorios');location.href ='javascript:history.back()';</script>";

}else{


    require("includes/PHPMailerAutoload.php");

    $mail = new PHPMailer();

    $mail->From     = ("[email protected]"); //Correo creado en el hosting
    //$mail->FromName = $nombre; 
    $mail->AddAddress("[email protected]"); //Correo de gmail donde se quiere que llegue el correo
// Dirección a la que llegaran los mensajes.

// Aquí van los datos que apareceran en el correo que reciba

    //$mail->WordWrap = 50; 
    $mail->IsHTML(true);     
    $mail->Subject  =  "";
    $mail->Body     =  '<html><body><br />'.
'<h2><font face="times new roman" color="#000000"><span><font face="times new roman" color="#00769f">Datos del cliente</h2></font>'.
    "<table style='border-style: solid;
    border-width: 1px; border-color:#A5D7DF;'><tr><td><strong>Pais</strong> </td><td>" . strip_tags($nombre) . "</td><br/></tr>".

    "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($email) . "</td></tr>".

     "<tr><td><strong>Compañia:</strong> </td><td>" . strip_tags($compania ) . "</td></tr>".

      "<tr><td><strong>Telefono:</strong> </td><td>" . strip_tags($telefono) . "</td></tr>".

       "<tr><td><strong>Estado / Pais:</strong> </td><td>" . strip_tags($pais) . "</td></tr>".


       "<tr><td><strong>Localidad/El cliente va a usar Videoconferencia proximamente:</strong> </td><td>" . strip_tags($videoconferencia) . "</td></tr>".




        '<tr><td></td></tr></table>'.

    "<br />";

// Datos del servidor SMTP

   // Datos del servidor SMTP
$mail->IsSMTP();
$mail->Host = "smtpout.secureserver.net";
$mail->Username = "[email protected]"; //Correo creado en el hosting
$mail->Password = "*******"; //Password
$mail->SMTPAuth = true;
$mail->Port = 25;

    if ($mail->Send())
    echo "<script>alert('Formulario Enviado');location.href ='';</script>";
    else
    echo "<script>alert('Error al enviar el formulario');location.href ='javascript:history.back()';</script>";

}
?>
    
asked by Alejandro Montes 30.05.2017 в 05:14
source

1 answer

1

Third edition

After consulting the Goddady documentation, the configuration of the outgoing server should be as follows:

So the code would be:

$mail->IsSMTP();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPAuth = false;
/* No es necesario realizar autenticación para el host local */
/*$mail->Username = "[email protected]"; //Correo creado en el hosting
$mail->Password = "*******"; //Password*/

You have a limit of 500 shipments per hour and 1000 shipments per day .

Second Edition

It seems that with new accounts, without a second authentication factor or without validating the phone number, they can not send mail using SMTP. A mail came to me indicating that an insecure application had been blocked, but there was no link to allow access or anything like that.

Enabling debugging (with $mail->SMTPDebug = true; ) you can see that the server responds with:

534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=aaaaaaaa
534-5.7.14 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
534-5.7.14 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
534-5.7.14 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
534-5.7.14 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14  Learn more at
534 5.7.14  https://support.google.com/mail/answer/78754 xxxxxxxxxxxx.99 - gsmtp

I followed the instructions that appeared on the help center gmail (I can not sign in to my email client) .

After giving access to less secure applications the problem persisted, so I proceeded to use the last method without success.

Finally I decided to use one of my accounts with the second authentication factor and I generated an application password .

With my email address as a user and that generated application password (it is generated randomly and you can not change it, just copy it to the clipboard and paste it into your code) you can send an email immediately.

So my recommendation is that you finalize the security and identity checks (if you have not already done so) and if you still can not send emails activate the second authentication factor and generate an application password.

Original reply

You have an error with the instance name of PHPMailer here:

$mailer->Host = 'smtp.gmail.com';  // Servidor de Salida.

It should be:

$mail->Host = 'ssl://smtp.gmail.com:465';  // Servidor de Salida.

On the next page you have an example of how to connect to Gmail:

link

So you could change your code to this one:

// Datos del servidor SMTP
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';  // Servidor de Salida.
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true; 
$mail->Username = "[email protected]";  // Correo Electrónico
$mail->Password = ""; // Contraseña
$mail->Mailer = "smtp";
    
answered by 30.05.2017 в 08:44