SMTP ERROR: Failed to connect to server: Connection refused

1

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

?>

Error:

  

SMTP ERROR: Failed to connect to server: Connection refused

    
asked by Alejandro Montes 01.06.2017 в 06:59
source

2 answers

1

I had that problem and I seem to remember that you had to use port 25, but it was a long time ago and I do not know if things have changed. Try with:

$mail -> Port = 25;
    
answered by 01.06.2017 в 09:47
0

Try modifying the smtp server to be used:

$mail->Host     = "relay-hosting.secureserver.net";
    
answered by 07.06.2017 в 14:00