0

I am facing the below error

2016-06-11 11:21:18 SMTP ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) 2016-06-11 11:21:18 SMTP connect() failed.

require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

$mail->isSMTP();
$mail->SMTPDebug = 2    ;                                  // Set mailer to use SMTP
$mail->Host = 'mail.example.com';                       // Specify main and backup server
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'alerts@example.com';                   // SMTP username
$mail->Password = 'indian@01';               // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
$mail->Port = 587;                                    //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('alerts@example.com',  'Greenvironment'); 
$mail->Subject = 'O&M - Data Monitoring Alert';
mail('test@gmail.com','Greenvironment - Data Monitoring','msg','headers');
                    $mail->Body    = '$msg';
                    $mail->send();

if(!$mail->send())
    {
       echo "Message could not be sent. <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;
       exit;
    }echo "success";

I have tried changing $mail->isSMTP(); to $mail->isMail(); . In this case, I'm not getting error. At the same time, I'm not receiving email also.

Kindly help me to resolve this issue. Thanks in Advance.

il_raffa
  • 5,090
  • 129
  • 31
  • 36
Sree
  • 1

0 Answers0