简体   繁体   English

SMTP 错误:连接服务器失败:由于目标机器主动拒绝,无法连接

[英]SMTP ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it

I am using phpMailer to Auto send mail to a specific user but it's throwing me ERROR as "2020-07-05 09:15:48 SMTP ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it. (10061) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting ERROR. Email is not sent.".我正在使用 phpMailer 自动向特定用户发送邮件,但它向我抛出错误“2020-07-05 09:15:48 SMTP 错误:无法连接到服务器:无法建立连接,因为目标机器主动拒绝它. (10061) SMTP connect() 失败。https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting ERROR。ZCE8AE9DA5B7CD6C3DF2929543A9AF92D 未发送。 Can anyone pls help me to resolve this.谁能帮我解决这个问题。

Here is my code:这是我的代码:

index.php index.php

<?php  
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 1;
$mail->HOST='smpt.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;
$mail->SMTPSecure='TLS';
$mail->Username='name@gmail.com';
$mail->Password='123';
$mail->setFrom('name@gmail.com', 'Tariq Shaikh');
$mail->addAddress('name1@gmail.com');
$mail->addReplyTo('name@gmail.com');
$mail->isHTML(true);
$mail->Subject='Notification';
$mail->Body='<h2 align=center>A new Audit Form has been Uploaded by Faculty.</h2><h3 align=center>Please check your Notification</h3>';

if (!$mail->send()) {
    echo "ERROR! Email is not sent!";
}
else{
    echo "Email has been sent successfully";
}

?> ?>

2 things: 2件事:

You should write 'smtp.gmail.com' not 'smpt.gmail.com'你应该写 'smtp.gmail.com' 而不是 'smpt.gmail.com'

PHP is case sensitive, so it must be $mail->Host and not $mail->HOST PHP 区分大小写,所以必须是 $mail->Host 而不是 $mail->HOST

暂无
暂无

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

相关问题 zend SMTP无法建立连接,因为目标计算机被主动拒绝 - zend SMTP No connection could be made because the target machine actively refused 无法建立连接,因为目标计算机主动拒绝了它的LARAVEL 4错误 - No connection could be made because the target machine actively refused it LARAVEL 4 error 由于目标机器主动拒绝连接,因此无法建立连接 - No connection could be made because the target machine actively refused it PHP Laravel:无法建立连接,因为目标机器主动拒绝它 - PHP Laravel: No connection could be made because the target machine actively refused it Mysql 无法连接,因为目标机器主动拒绝 - Mysql No connection could be made because the target machine actively refused it 无法建立连接,因为目标计算机主动拒绝了它Laravel 5 - No connection could be made because the target machine actively refused it Laravel 5 PHP-无法建立连接,因为目标计算机主动拒绝了它 - PHP- No connection could be made because the target machine actively refused it 无法建立连接,因为目标机器主动拒绝它。 WordPress的 - No connection could be made because the target machine actively refused it. wordpress 警告:mysql_connect():由于目标计算机主动拒绝连接,因此无法建立连接 - Warning: mysql_connect(): No connection could be made because the target machine actively refused it 无法连接到数据库,并显示错误消息(HY000 / 2002):无法建立连接,因为目标计算机主动拒绝了它 - Can't connect to database with error (HY000/2002): No connection could be made because the target machine actively refused it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM