【问题标题】:php mail function not working in new serverphp邮件功能在新服务器中不起作用
【发布时间】:2020-01-16 08:28:54
【问题描述】:

背景

我的visitmeemure.com 托管在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 功能。

谢谢

【问题讨论】:

  • 你试过 PHP Mailer 库吗?
  • 他们不允许 mail() 的主要原因是与其他高级选项相比,它的安全性 abs 功能级别较低。请尝试github.com/PHPMailer/PHPMailer
  • @Alpha 你的意思是php邮件功能

标签: php server smtp port phpmailer


【解决方案1】:

有一个名为 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 下载并手动将其放在那里

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

【讨论】:

    猜你喜欢
    • 2012-01-10
    • 2014-03-16
    • 2016-12-07
    • 1970-01-01
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 2013-01-25
    • 1970-01-01
    相关资源
    最近更新 更多