PHP mail: What does -f do?

前端 未结 3 1803
鱼传尺愫
鱼传尺愫 2021-01-17 11:35

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. What does the \"-f\" flag do and why would

3条回答
  •  一整个雨季
    2021-01-17 12:32

    -f is a parameter to the mailer (usually 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. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

    Here is the man page for sendmail, you can see what the -f option does:

    -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.
    

提交回复
热议问题