我有一个 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/