Smtp Webmin上的Postfix邮件服务器。无法连接到服务器,权限被拒绝(13)

Smtp Webmin上的Postfix邮件服务器。无法连接到服务器,权限被拒绝(13),smtp,phpmailer,postfix-mta,webmin,Smtp,Phpmailer,Postfix Mta,Webmin,我使用PHPMailer发送电子邮件,它在localhost上运行得非常好。然而,根据客户的要求,我们必须将所有内容上传到webmin。正在为我们安装PostFix邮件服务器。问题是我无法在服务器上使用电子邮件功能 这是我的密码 <?php require_once('class.phpmailer.php'); $mail = new PHPMailer(); $body = 'Test Email'; $mail->IsSMTP(); // tell

我使用PHPMailer发送电子邮件,它在localhost上运行得非常好。然而,根据客户的要求,我们必须将所有内容上传到webmin。正在为我们安装PostFix邮件服务器。问题是我无法在服务器上使用电子邮件功能

这是我的密码

<?php
require_once('class.phpmailer.php');

$mail             = new PHPMailer();

$body = 'Test Email';

$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                       // 1 = errors and messages
                                       // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "smtp.xxx.xxx.xx";
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "";
$mail->Password   = "";
$mail->SMTPSecure = 'tsl';

$mail->SetFrom('support@xxx.xxx', 'Support');

$mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "xxx@hotmail.com";
$mail->AddAddress($address, "Sara Chan");

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

?>

错误消息: SMTP错误:无法连接到服务器:权限被拒绝(13)SMTP connect()失败。邮件程序错误:SMTP连接()失败

我已经尝试过配置postfix main.cf文件,但仍然不起作用。 我试过:


  • 这些链接的配置不同。我是一名新的PHP程序员(还是一名本科生),所有这些都让人困惑。现在,我的postfix main.cf回到了“默认”状态。我现在该怎么办?

    看起来您使用的是旧版本的PHPMailer,所以

    如果您是从与脚本相同的服务器发送的(因为您正在配置postfix,所以听起来像是这样),请不要使用SMTP,请调用
    IsMail()
    IsSendmail()
    函数,而不是
    IsSMTP()

    没有像“tsl”这样的SMTP安全模式——您想到的是“tls”,如果您要使用它,它可能位于端口587上,而不是端口25上


    如果通过邮件或sendmail发送,则无需提供身份验证凭据。

    我在Oracle Linux 7.7服务器上遇到了相同的错误,并通过输入以下命令解决了该错误:

    sudo setsebool-p httpd_can_sendmail 1
    sudo setsebool-P httpd_can_网络_连接1