php - 如何使用 PHPmailer 使用 Postfix 配置和发送邮件?

标签 php smtp phpmailer postfix-mta

我有一个 PHPmailer 类,是从示例中下载的。我配置并安装了Postfix和mailutils,但我不知道用postfix配置phpmailer的参数。我按原样尝试,但收到错误:SMTP 错误:无法进行身份验证。

  public $From          = '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cba6ae8baeb3aaa6bba7aee5a8a4a6" rel="noreferrer noopener nofollow">[email protected]</a>';
  public $FromName      = 'Me';
  public $Host          = 'localhost';
  public $Port          = 25;
  public $Helo          = '';
  public $SMTPSecure    = ''; // empty, ssl or tls
  public $SMTPAuth      = false;
  public $Username      = '';
  public $Password      = '';

我必须如何配置 /etc/postfix/main.cf 配置文件以及我必须在 PHPmailer 字段中插入哪些内容?

最佳答案

PHPmailer 将通过调用 php mail() 函数并使用 postfix 作为发出请求的用户来发送邮件。例如,在基于 Ubuntu 的系统上,如果 apache 使用 PHP 调用,则该数据将为 www-data。简而言之,只要 SMTPAuth = true; 设置为 NOT,就不需要进行身份验证。仅当您连接到远程邮件服务器以进行身份​​验证和传送邮件时才需要 SMTPAuth

解决您的问题。 删除与 SMTPAuth 相关的行以使用本地安装的 postfix 服务器。

您可以引用https://github.com/PHPMailer/PHPMailer/tree/master/examples使用 PHPmailer 的各种示例。

关于php - 如何使用 PHPmailer 使用 Postfix 配置和发送邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41724599/

相关文章:

php - 使用 XAMPP、sendmail 和 gmail smtp 服务器发送邮件

php - 没有回复的线程 : Message-ID?

php - 使用 bash 或 php 获取文件夹层次结构

批量电子邮件期间的 javamail 与 sendmail 性能

php - 这是使我的网站对 google 友好的正确方法吗?

smtp - 远程服务器上的 Postfix SMTP 响应 554 rcpt(收件人)的中继访问被拒绝。在 'localhost' smtp 服务器上工作正常

PHPMailer - 无法验证

php - 如何使用 PHPMailer 将 HTML、CSS 和 PHP 添加到电子邮件中?

javascript - 多个条件到一个复选框

php - mysql数据库中没有记录时间