简体   繁体   English

SMTP错误:无法连接到服务器:使用PHPMailer和Outlook SMTP连接超时(110)

[英]SMTP ERROR: Failed to connect to server: Connection timed out (110) with PHPMailer and Outlook SMTP

I am getting SMTP Error with PHP Mailer and Outlook SMTP. 我正在使用PHP Mailer和Outlook SMTP获得SMTP错误。 I am confused here because it is working fine on localhost with Port number 25 but It is not working on Hosting Server, I have tried all ports with SSL & TLS. 我在这里很困惑,因为它在端口号为25的localhost上工作正常,但它不能在Hosting Server上工作,我已尝试使用SSL和TLS的所有端口。

Error : SMTP ERROR: Failed to connect to server: Connection timed out (110) 错误: SMTP错误:无法连接到服务器:连接超时(110)



My Code: 我的代码:

<?php

include("PHPMailer.php"); 

error_reporting(E_ALL);
ini_set('display_errors', '1');

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.live.com";
$mail->SMTPDebug = 2;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "info@neelcomputech.com";
$mail->Password = "password";
$mail->Priority    = 1;
$mail->CharSet     = 'UTF-8';
$mail->ContentType = 'text/html; charset=utf-8\r\n';

$mail->From = "info@neelcomputech.com";
$mail->FromName = $name;
$mail->AddAddress("info@neelcomputech.com");

$mail->IsHTML(true);

$mail->Subject = "You got Message from Website";
$mail->Body = "testing";

if(!$mail->Send())
{
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else
{
    echo 'success';
}

?>


Please help me to solve this issue. 请帮我解决这个问题。 I have Shared Linux Hosting. 我有共享Linux主机。

I had a similar problem, and it turned out my host (Bluehost) blocked outgoing connections on port 465. I will post the solution here in the hope that helps you. 我有一个类似的问题,结果我的主机(Bluehost)阻止了端口465上的传出连接。我将在这里发布解决方案,希望能帮到你。 But I'm not expert enough to know if it's the same problem or not. 但我不够专业,不知道是否是同一个问题。

I found a wonderful how-to which fixed it for me: 我找到了一个很好的操作方法 ,为我修好了它:

  1. In your cPanel DNS Zone editor, find the MX (Mail Exchanger) section, and select 'remote mail exchanger'. 在cPanel DNS区域编辑器中,找到MX(邮件交换器)部分,然后选择“远程邮件交换器”。
  2. In the cPanel email accounts section, create the appropriate email address (don't skip this) 在cPanel电子邮件帐户部分中,创建相应的电子邮件地址(不要跳过此内容)
  3. Don't use "smtp.live.com" as your smtp host. 不要使用“smtp.live.com”作为smtp主机。 Use the smtp host of your Shared Linux Hosting smtp. 使用您的Shared Linux Hosting smtp的smtp主机。 I don't know how you will get yours. 我不知道你会如何得到你的。 Mine is boxXXXX.bluehost.com. 我的是boxXXXX.bluehost.com。
  4. Set your username and password to be the same as the email account you just set-up in cPanel. 将您的用户名和密码设置为与您在cPanel中设置的电子邮件帐户相同。

None of the answers worked for me. 这些答案都不适合我。 After many hours, I found the problem, but only works for Cpanel/WHM 几个小时后,我发现了问题,但只适用于Cpanel / WHM

  • Login into WHM. 登录WHM。
  • Go to ConfigServer Security & Firewall inside plugins option. 转到ConfigServer Security&Firewall inside plugins选项。
  • Click on Firewall configuration 单击防火墙配置
  • Filter by SMTP Settings 按SMTP设置过滤
  • Look for SMTP_ALLOWUSER option and add the Cpanel account's username separated by coma 查找SMTP_ALLOWUSER选项并添加由昏迷分隔的Cpanel帐户的用户名
  • Restart the Firewall. 重启防火墙。

If you don't have access to WHM ask your provider. 如果您无法访问WHM,请咨询您的提供商。

Hope it helps! 希望能帮助到你!

Mos probably phpmailer not supported by your hosting. 你的主机不支持Mos phpmailer。 You must have to cross check by creating new file and check simple php email function. 您必须通过创建新文件并检查简单的php电子邮件功能来进行交叉检查。 Most probably SMTP not configure at your hosting provider 很可能SMTP不在您的托管服务提供商处配置

<?php
$to = "somebody@example.com";
$subject = "My subject";

$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";

mail($to,$subject,$headers);
?>

My code is correct. 我的代码是正确的。
The issue was with Hosting Provider. 问题在于托管服务提供商。 I contacted them about this and they did some configuration on their Server and it's done. 我联系了他们,他们在他们的服务器上做了一些配置,就完成了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHPMailer的臭名昭著的SMTP错误:无法连接到服务器:连接超时(110)SMTP connect()失败 - PHPMailer's infamous SMTP ERROR: Failed to connect to server: Connection timed out (110) SMTP connect() failed PHPMailer SMTP无法连接到服务器:连接超时(110)到Gmail - PHPMailer SMTP Failed to connect to server: Connection timed out (110) to Gmail SMTP 错误:无法连接到服务器:使用 phpmailer 时连接超时(110) - SMTP ERROR: Failed to connect to server: Connection timed out (110) when using phpmailer SMTP-&gt;错误:无法连接到服务器:连接超时(110) - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP-&gt;错误:无法连接到服务器:连接超时(110)SMTP错误:无法连接到SMTP主机。 - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP Error: Could not connect to SMTP host. 无法连接到服务器:连接超时(110)SMTP Connect()失败。 邮件未发送。邮件错误:SMTP Connect()失败 - Failed to connect to server: Connection timed out (110)SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed SMTP-&gt;错误:无法连接到服务器:连接超时(110)以下“发件人”地址失败:xxxxx@gmail.com错误 - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: xxxxx@gmail.com ERROR PHPMailer 错误:SMTP -&gt; 错误:无法连接到服务器 - PHPMailer error: SMTP -> ERROR: Failed to connect to server PHPMailer SMTP错误:无法连接到服务器 - PHPMailer SMTP ERROR: Failed to connect to server PHPMailer:SMTP 错误:无法连接到服务器:(0)与godaddy - PHPMailer: SMTP ERROR: Failed to connect to server: (0) with godaddy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM