I am implementing mail functionality by using PHP mailer. The code is not working on online but its working on local machine. On local machine code sends the mail successfully but on online website it is showing following error:
SMTP -> ERROR: Failed to connect to server: ()
SMTP Error: Could not connect to SMTP host.
Code is:
<?php
include "classes/class.phpmailer.php"; // include the class name
$mail1 = new PHPMailer(); // create a new object
$mail1->IsSMTP(); // enable SMTP
$mail1->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail1->SMTPAuth = true; // authentication enabled
$mail1->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail1->Host = "smtp.gmail.com";
$mail1->Port = 465; // or 587
$mail1->IsHTML(true);
$mail1->Username = "yourmail@gmail.com";
$mail1->Password="password";
$mail1->SetFrom("yourmail@gmail.com");
$mail1->Subject = "Working";
$mail1->Body ="Hi, you got email";
$mail1->AddAddress("yourmail2@gmail.com");
$mail1->Send();
?>
Aucun commentaire:
Enregistrer un commentaire