php / php/php-src

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

Aperta
#20,648 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug SAPI: fpm Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Esamina sapi/fpm/www.conf.in e l’esempio commentato esistente di sendmail_path. Rimuovi l’opzione -f dall’esempio mantenendo la dimostrazione di php_admin_value, quindi verifica che il valore documentato corrisponda alla forma proposta nell’issue e non imponga un indirizzo del mittente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
backend
Tipo di issue
Documentazione
Difficoltà
1/5
Tempo stimato
Meno di un'ora
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.