PHP邮件:-f做什么?

时间:2011-11-29 06:03:59

标签: php

在对电子邮件主机的联系表单进行疑难解答时,他们告诉我在php邮件功能的起始地址使用'-f'。 “-f”标志的作用是什么?为什么这将是允许发送电子邮件的修复程序?我读了一些文档,但我不是很清楚。

示例代码:

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

PS:没有“-f”它适用于大型电子邮件主机(hotmail,gmail等,但无论出于何种原因,不适用于我正在使用的较小主机)

由于

3 个答案:

答案 0 :(得分:10)

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

  

additional_parameters参数可用于传递其他内容   flags作为配置为使用的程序的命令行选项   发送邮件时,由sendmail_path配置定义   设置。 例如,这可用于设置信封发件人   将sendmail与-f sendmail选项一起使用时的地址。

以下是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.

答案 1 :(得分:3)

-f选项用于设置退回邮件地址。发送没有消息的消息可能会对通过消息计算的垃圾邮件分数产生负面影响。对于某些主机,分数较低的消息有时会被过滤掉。

您可以使用MSDN来测试邮件的分数。您可以在有或没有-f标志的情况下过期,并查看分数变化。

答案 2 :(得分:2)

这是一个标记以下文本($ mailFrom)的标志,用作邮件的“发件人”地址。

查看:http://www.php.net/manual/en/function.mail.php