php 新服务器无法使用邮件功能

php mail function not working in new server

背景

我的 visitmeemure.com was hosted in ipage server 一切正常。

然后我将我的网站移至 smartersap.net,现在当有人提交联系我们表格时我收到以下错误。

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in H:\root\home\cmadurawala-001\www\aaaa\contact.php on line 77

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in H:\root\home\cmadurawala-001\www\www\aaaa\contact.php on line 79

所以我联系了服务器管理员,他们说不支持php邮件功能,我必须申请smtp认证在申请中.

谁能告诉我如何解决这个问题。我目前正在我网站的联系页面中使用 php mail 功能。

谢谢

有一个名为 PHPMailer 的库。您可以使用它代替本机 mail() 函数。这就是使用 PHPMailer

时代码的样子
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';
// here you create the mail object
$mail = new PHPMailer(true);

我建议使用 composer 安装库及其依赖项。 但是,由于您的应用程序已经在服务器中,您可以从 GitHub 下载 if 并手动将其放在那里

更多信息: https://github.com/PHPMailer/PHPMailer