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

时间:2014-06-30 03:50:46

标签: smtp phpmailer postfix-mta webmin

我使用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连接()失败。邮件程序错误:SMTP连接()失败。

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

  1. http://postfix.state-of-mind.de/patrick.koetter/smtpauth/postfix_configuration.html
  2. http://www.postfix.org/BASIC_CONFIGURATION_README.html
  3. http://wiki.centos.org/HowTos/postfix
  4. http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
  5. 这些链接的配置不同。我是一名新的PHP程序员(仍然是本科生),所有这些都让人感到困惑。现在,我的postfix main.cf又回到了'默认'状态。我现在该怎么办?

2 个答案:

答案 0 :(得分:0)

您似乎正在使用旧版本的PHPMailer,因此update that

如果您从与脚本相同的服务器发送(由于您正在配置postfix,它听起来就是这样),请不要使用SMTP,请致电IsMail()IsSendmail()功能代替IsSMTP()

没有像&#39; tsl&#39;这样的SMTP安全模式。 - 你正在考虑&#39; tls&#39;如果你打算使用它,它可能会在587端口而不是25端。

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

答案 1 :(得分:0)

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

sudo setsebool -P httpd_can_sendmail 1
sudo setsebool -P httpd_can_network_connect 1

相关问题