php / php/php-src

Example value for sendmail_path in sapi/fpm/www.conf.in seems to be encouraging bad practice

オープン
#20,648 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug SAPI: fpm Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The file sapi/fpm/www.conf.in currently contains the following line:

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com

I think the intent of this is really to illustrate the use of php_admin_value rather than provide guidance on setting sendmail_path; however, I think a lot of people actually want to configure their sendmail_path and then they see this example, and then they blindly copy and paste it (just changing the path and email address as needed) without really thinking about it much. The problem is that including the -f option in sendmail_path is generally a bad practice and should be avoided.

The reason this is bad is that the PHP mail() function has a parameter $additional_params which is intended to be used to specify the -f option. But if you specify an -f option in $additional_params and there is already an -f option in sendmail_path, you end up passing the -f option to sendmail twice. This may cause sendmail to fail completely, possibly with an error message like More than one "from" person.

For many, many years, there have been lots of people having trouble with this:

https://mantisbt.org/forums/viewtopic.php?t=24647
https://github.com/magento/magento2/issues/20033#issuecomment-532289611
https://bugs.php.net/bug.php?id=53984
https://github.com/bcit-ci/CodeIgniter/issues/4343
https://forum.joomla.org/viewtopic.php?f=622&t=727375
https://www.vmayo.com/docs/fixed-phpmailer-smtp-error-could-not-connect-to-smtp-host-2/#11-toc-title
... and so on ...

I was wondering why there seem to be so many people dealing with poorly configured sendmail_path values... I think at least part of the problem may be this example code in the PHP-FPM www.conf file.

Can this example be changed to something else? Maybe something like this:

;php_admin_value[sendmail_path] = /path/to/sendmail -t -i
PHP Version
This issue has existed in every PHP version since PHP-FPM was merged into it (and possibly it existed in the separate PHP-FPM project before that).
Operating System

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

sapi/fpm/www.conf.in と既存のコメントアウトされた sendmail_path の例を確認します。php_admin_value のデモンストレーションは維持したまま、例から -f オプションを削除し、その後、ドキュメントに記載された値が issue で提案された形式と一致し、送信者アドレスを指定していないことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
backend
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1時間未満
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。