I am using email/office from godaddy and I have a php page, which will send an email but it seems something block from godaddy as I am getting following error
Error: SMTP -> ERROR: Failed to connect to server: Connection refused (111)SMTP Connect() failed.
Why Connection refused? Is there any setup, which I missed? What could be the issue, I tried Gmail smtp as well and Cpanel email seems it is fine but some time the email got delay and sometimes not sent. I want to use my office 365 one.
To check the error: http://iclicks.co/uc_sipc/test_email.php
Here is my coding and note that it is running fine with gmail smtp in my local PC:
<?php
//send_email1();
send_email1();
function send_email1()
{
require 'class/class.phpmailer.php';
try
{
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->Host = 'smtp.office365.com';
$mail->Port = '587';
$mail->SMTPAuth = true;
$mail->Username = 'services@iclicks.co';
$mail->Password = '***********';
$mail->SMTPDebug = 1;
$mail->SMTPSecure = 'tls';
$mail->From = 'services@iclicks.co';
$mail->FromName = 'Mahmood';
$mail->AddAddress('maa8868@gmail.com', 'Mahmood');
$mail->AddCC ('maa8868@gmail.com', 'Commercial Team');
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = 'test';
$mail->Body = 'test tes test';
$error='';
var_dump($mail->Send());
exit();
if($error=$mail->Send())
{
$error = '<label class="text-success"> Thank you for contacting us, please check your email </label>';
//$query = mysqli_query($mysqli, "INSERT INTO mail_logs (log_toname , log_tocompany, log_toposition, log_tomail ,log_status,log_date) VALUES ('$fname', '$company', '$position','$email', 'Sent Succesfully','$date')") ;
echo "Email sent";
//header('Location: /projects/uc_sipc/index.php');
}
else
{
//$error = '<label class="text-danger">Erroe: Failed to send email.</label>';
//header('Location: /projects/uc_sipc/index.php');
echo ('Erroe: Failed to send email'.$error );
}
}catch (Exception $e)
{
echo ('Exception: '.$e);
}
echo ('Functon ended up');
}
?>