我正在使用Godaddy的电子邮件/办公室,并且我有一个php页面,该页面将发送电子邮件,但是由于我遇到以下错误,因此似乎对Godaddy有所阻止
错误: SMTP->错误:无法连接到服务器:连接被拒绝(111)SMTP Connect()失败。
为什么连接被拒绝?有没有我错过的设置? 可能是问题所在,我也尝试了Gmail smtp,Cpanel电子邮件似乎还可以,但是有时电子邮件延迟了,有时没有发送。 我要使用我的Office 365之一。
要检查错误:http://iclicks.co/uc_sipc/test_email.php
这是我的编码,请注意,在本地PC上使用gmail smtp可以正常运行:
<?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');
}
?>