0

I have a simple php contact form. It works perfectly in localhost, I uploaded to godaddy server and it simply does not work. I found many blogs about it but all of them are from 5 years ago. This is the code:

require("../../phpmailer/class.phpmailer.php");

$mail = new PHPMailer();
$mail->Username = "mail@gmail.com"; 
$mail->Password = "password"; 
$mail->AddAddress("mail@gmail.com"); 
$mail->FromName = "Dolph"; // readable name
$mail->Subject = "Subject title";

$mail->Body = "Nombre: ". $_POST['nombre'] ."\r\n" . "Email: ". $_POST['email'] ."\r\n" . 
              "Telefono: ". $_POST['numero'] ."\r\n" . "Comentario: ". $_POST['comentario'] ."\r\n";


$mail->Host = "relay-hosting.secureserver.net"; // GMail
$mail->Port = 465;
$mail->IsSMTP(); // use SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->From = $mail->Username;
if(!$mail->Send())
    echo "<div class='alert alert-danger' role='alert'>¡Su correo no se envió exitosamente!</div>";
else
    echo "<div class='alert alert-success' role='alert'>¡Su correo se envió exitosamente!</div>";
}

Please help me with this issue. Thanks developers.

tripleee
  • 139,311
  • 24
  • 207
  • 268
  • why not use the mail server of your host? –  Sep 07 '15 at 20:16
  • Have you considered enabling `->SMTPDebug` to find out why it doesn't work? – mario Sep 07 '15 at 20:17
  • This is the error what it shows: SMTP Error: The following recipents failed: mymail@gmail.com SMTP server error: Please turn on SMTP Authentication in your mail client. xxxxxxxxxxxxxx-secureserver.net 5xx-[] is not permitted to relay through this server without 550 authentication –  Sep 07 '15 at 20:27
  • It also shows me this when I change the host. Mailer Error: The following From address failed: mymail@gmail.com : Called Mail() without being connected –  Sep 07 '15 at 20:49

1 Answers1

1

This is a very well known problem, and there are a zillion questions and answers on here saying this: GoDaddy blocks outbound SMTP. You either need to ask them to allow it or use their mail servers.

Synchro
  • 29,823
  • 14
  • 69
  • 85