简体   繁体   English

PHP邮件:-f做什么?

[英]PHP mail: What does -f do?

While troubleshooting a contact form with an e-mail host they told me to use '-f' in the from address of the php mail function. 在对电子邮件主机的联系表单进行故障排除时,他们告诉我在php邮件功能的发件人地址中使用“-f”。 What does the "-f" flag do and why would that be a fix for allowing an e-mail to be delivered? “-f”标志的作用是什么?为什么这将是允许发送电子邮件的修复程序? I read some of the documentation but I'm not quite clear on it. 我读了一些文档,但我不是很清楚。

Example code: 示例代码:

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

PS: without the "-f" it works just fine for the big e-mail hosts (hotmail, gmail, etc, but for whatever reason not for the smaller host I'm working with) PS:没有“-f”它适用于大型电子邮件主机(hotmail,gmail等),但出于任何原因不适用于我正在使用的较小主机

Thanks 谢谢

-f is a parameter to the mailer (usually sendmail). -f是邮件程序的参数(通常是sendmail)。 From 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. additional_parameters参数可用于将其他标志作为命令行选项传递给配置为在发送邮件时使用的程序,如sendmail_path配置设置所定义。 For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option. 例如,当使用带有-f sendmail选项的sendmail时,可以使用此选项设置信封发件人地址。

Here is the man page for sendmail , you can see what the -f option does: 这是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.

The -f option is to set the bounce mail address. -f选项用于设置退回邮件地址。 Sending a message without one can negatively influence the spam-score that is being calculated over the message. 发送没有消息的消息可能会对通过消息计算的垃圾邮件分数产生负面影响。 Messages with low scores sometimes get filtered out for certain hosts. 对于某些主机,分数较低的消息有时会被过滤掉。

You can use https://www.mail-tester.com/ to test the score of your message. 您可以使用https://www.mail-tester.com/来测试邮件的分数。 You can expirement with or without the -f flag and see the score change. 您可以使用或不使用-f标志过期,并查看分数更改。

It is a flag to mark the following text ($mailFrom) to be used as "from" address of the mail. 它是一个标记以下文本($ mailFrom)的标志,用作邮件的“发件人”地址。

Have a look at: http://www.php.net/manual/en/function.mail.php 看看: http//www.php.net/manual/en/function.mail.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM