【问题标题】:How to configure and send mail with Postfix using a PHPmailer?如何使用 PHPmailer 使用 Postfix 配置和发送邮件?
【发布时间】:2017-06-03 03:17:43
【问题描述】:

我有一个 PHPmailer 类,从一个示例下载。我配置并安装了 Postfix 和 mailutils,但我不知道使用 postfix 配置 phpmailer 的参数。我按原样尝试,但出现错误:SMTP Error: Could not authenticate.

  public $From          = 'me@example.com';
  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 字段中插入什么?

【问题讨论】:

  • 所以你需要再次点击手册
  • 你的问题太模糊了......你可能想发布你的 postfix 配置文件,甚至在此之前,在 localhost 的端口 25 上运行 wireshark 或 tcpdump,看看你的 phpmailer 如何与 postfix 通信。通常,默认的后缀配置不需要在本地主机上进行任何身份验证。
  • 我不明白phpmailer是什么意思,如果用户名和密码与系统相关,我不知道是什么。请帮助我,因为我知道的很少。 @垃圾邮件
  • 好的。也许只是写下你想要完成的事情。

标签: php smtp phpmailer postfix-mta


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2021-03-05
    • 1970-01-01
    • 2020-06-28
    • 2013-11-29
    • 2020-04-05
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多