PHP 邮件 : What does -f do?

标签 php

在对电子邮件主机的联系表单进行故障排除时,他们告诉我在 php 邮件功能的发件人地址中使用“-f”。 “-f”标志的作用是什么?为什么它可以解决允许发送电子邮件的问题?我阅读了一些文档,但不是很清楚。

示例代码:

mail($emailAddress, $mailSubject, $mailBody, $headers, '-f ' . $mailFrom);

PS:如果没有“-f”,它对大型电子邮件主机(hotmail、gmail 等,但出于某种原因不适用于我正在使用的小型主机)来说效果很好

谢谢

最佳答案

-f 是邮件程序(通常是 sendmail)的参数。来自 the docs :

The additional_parameters parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail, as defined by the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

这是 man page for sendmail ,您可以看到 -f 选项的作用:

-fname           Sets the name of the ``from'' person (i.e., the sender of the
                 mail).  -f can only be used by ``trusted'' users (normally
                 root, daemon, and network) or if the person you are trying to
                 become is the same as the person you are.

关于PHP 邮件 : What does -f do?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8306576/

相关文章:

php - 在 PhP5 中,有没有办法获取我所有服务器的 IP 地址?

PHPUnit错误 undefined variable

PHP-MYSQL语法错误

php - 如何在 php 中动态地将图像从 mysql 数据库插入到 jquery slider 中

php - 安装 SOAP 扩展 PHP 配置 (AWS)

javascript - 如何编辑wordpress主题的索引页?

php - 样式表未链接

php - php-ews 中的 DistinguishedFolderId->Mailbox->EmailAddress 是什么?

php - PHP套接字: From php server to web client

php - 添加将在 PHP 中以 JSON 编码的 mysql 查询结果的值?