我有 2 个网站:AWS中的https://www.nubeduc.cl/和更便宜的共享主机中的http://www.nubeduc.com/。我使用 PHPMailer 的脚本来发送电子邮件,但是这个脚本只适用于 nubeduc.com 在这两个服务器中,今天下载的 PHPMailer 文件都在文件夹 src 中(http://www.nubeduc.com/scr/和https://www .nubeduc.cl/scr/)我创建了一个名为“smtp.php”的php文件用于测试目的:(http://www.nubeduc.com/smtp.php和https://www.nubeduc.cl/smtp。 php )
<?php
/**
* This example shows making an SMTP connection with authentication.
*/
//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require 'src/PHPMailer.php';
require 'src/SMTP.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// SMTP::DEBUG_OFF = off (for production use)
// SMTP::DEBUG_CLIENT = client messages
// SMTP::DEBUG_SERVER = client and server messages
$mail->SMTPDebug = SMTP::DEBUG_LOWLEVEL;
//Set the hostname of the mail server
$mail->Host = 'mail.nubeduc.com';
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 25;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = 'mailer@nubeduc.com';
//Password to use for SMTP authentication
当我在 nubeduc.com 中运行这个脚本时,它的工作就像一个魅力。您可以尝试检查调试日志。但是当我在 110 秒后在 nubeduc.cl 中运行时,会在屏幕上显示这些错误:
2020-03-04 20:25:20 Connection: opening to mail.nubeduc.com:25, timeout=300, options=array()
2020-03-04 20:27:30 Connection failed. Error #2: stream_socket_client(): unable to connect to mail.nubeduc.com:25 (Connection timed out) [/var/www/nubeduc.cl/src/SMTP.php line 349]
2020-03-04 20:27:30 SMTP ERROR: Failed to connect to server: Connection timed out (110)
现在我更新了 Ubuntu 实例,检查 php openssl 扩展(处于活动状态),但没有任何效果。为什么该脚本在我的 AWS 站点中不起作用?请帮忙!!!
噜噜哒