php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73492 PHP 5.6 ini_set no longer supports sendmail_path; must be hard-coded in php.ini
Submitted: 2016-11-10 22:41 UTC Modified: 2016-11-11 10:20 UTC
From: php dot net at ii0 dot net Assigned: cmb (profile)
Status: Not a bug Package: PHP options/info functions
PHP Version: 5.6.28 OS: Red Hat
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php dot net at ii0 dot net
New email:
PHP Version: OS:

 

 [2016-11-10 22:41 UTC] php dot net at ii0 dot net
Description:
------------
---
From manual page: http://www.php.net/function.ini-set
---

Historically, we have been able to dynamically set the path to a sendmail binary:
ini_set('sendmail_path','/path/to/sendmail -xyz');
and everything worked well.

However, after upgrading PHP to 5.6, it seems that PHP suddenly ignores that particular setting (or quietly fails to use it) because all PHP-initiated mail totally stops working and the PHP error log gives us [a cryptic and ultimately unhelpful] error "sh: -t: command not found".  

Hard-coding the path in the php.ini file works fine:
sendmail_path = /path/to/sendmail -xyz

Fortunately for us, the dynamic setting via ini_set() is unnecessary because we only have one version of the sendmail binary and all PHP-initiated mail can use the same parameters.  Hard-coding it is acceptable in our case.

Whether this behavior change is a feature or a bug, it should be documented.  If this is the new intentional behavior then ideally, ini_set() should raise a deprecation/warning/etc. when someone tries to use it for sendmail_path.

BTW: It appears that all our other ini_set() besides sendmail_path are still working in 5.6 just as they did before.


Here is the "configure" entry from phpinfo(), in case anyone finds it useful:

'./configure' '--prefix=/opt/lampp' '--with-apxs2=/opt/lampp/bin/apxs' '--with-config-file-path=/opt/lampp/etc' '--with-mysql=mysqlnd' '--enable-inline-optimization' '--disable-debug' '--enable-bcmath' '--enable-calendar' '--enable-ctype' '--enable-ftp' '--enable-gd-native-ttf' '--enable-magic-quotes' '--enable-shmop' '--disable-sigchild' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--with-gdbm=/opt/lampp' '--with-jpeg-dir=/opt/lampp' '--with-png-dir=/opt/lampp' '--with-freetype-dir=/opt/lampp' '--with-zlib=yes' '--with-zlib-dir=/opt/lampp' '--with-openssl=/opt/lampp' '--with-xsl=/opt/lampp' '--with-ldap=/opt/lampp' '--with-gd' '--with-imap=/bitnami/xamppunixinstallerstackDev-linux-x64/src/imap-2007e' '--with-imap-ssl' '--with-gettext=/opt/lampp' '--with-mssql=shared,/opt/lampp' '--with-pdo-dblib=shared,/opt/lampp' '--with-sybase-ct=/opt/lampp' '--with-mysql-sock=/opt/lampp/var/mysql/mysql.sock' '--with-oci8=shared,instantclient,/opt/lampp/lib/instantclient' '--with-mcrypt=/opt/lampp' '--with-mhash=/opt/lampp' '--enable-sockets' '--enable-mbstring=all' '--with-curl=/opt/lampp' '--enable-mbregex' '--enable-zend-multibyte' '--enable-exif' '--with-bz2=/opt/lampp' '--with-sqlite=shared,/opt/lampp' '--with-sqlite3=/opt/lampp' '--with-libxml-dir=/opt/lampp' '--enable-soap' '--with-xmlrpc' '--enable-pcntl' '--with-mysqli=mysqlnd' '--with-pgsql=shared,/opt/lampp/' '--with-iconv=/opt/lampp' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=/opt/lampp/postgresql' '--with-pdo_sqlite=/opt/lampp' '--with-icu-dir=/opt/lampp' '--enable-fileinfo' '--enable-phar' '--enable-zip' '--enable-intl' 'CC=gcc' 'CFLAGS=-I/opt/lampp/include/c-client '-I/opt/lampp/include/libpng' '-I/opt/lampp/include/freetype2' '-O3' '-fPIC' '-L/opt/lampp/lib' '-I/opt/lampp/include' '-I/opt/lampp/include/ncurses'' 'LDFLAGS=-Wl,--rpath '-Wl,/opt/lampp/lib' '-L/opt/lampp/lib' '-I/opt/lampp/include' '-L/opt/lampp/lib' '-L/opt/lampp'' 'CPPFLAGS=-I/opt/lampp/include/c-client '-I/opt/lampp/include/libpng' '-I/opt/lampp/include/freetype2' '-O3' '-fPIC' '-L/opt/lampp/lib' '-I/opt/lampp/include' '-I/opt/lampp/include/ncurses'' 'CXX=g++' 'CXXFLAGS=-I/opt/lampp/include/c-client '-I/opt/lampp/include/libpng' '-I/opt/lampp/include/freetype2' '-I/opt/lampp/include/ncurses' '-O3' '-L/opt/lampp/lib' '-I/opt/lampp/include''

Test script:
---------------
<?php

// to reproduce the problem, ensure php.ini has no hard-coded sendmail_path
ini_set("sendmail_path", "/usr/sbin/sendmail -t -i"); 

// this returns false, and "sh: -t: command not found" will appear in the error log
mail( "recipient@ii0.net", "subject here", "body here", "From: sender@ii0.net\r\n" );



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-11 10:20 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-11-11 10:20 UTC] cmb@php.net
sendmail_path is PHP_INI_SYSTEM at least as of PHP 4.3[1], so changing
it with ini_set() shouldn't have been possible at all. That is already
documented[2].

Since ini_set() signals success/failure with its return value, I don't
think there needs to be an additional warning or notice. Just check its
return value instead.

[1] <https://github.com/php/php-src/blob/PHP-4.3/main/main.c#L359>
[2] <http://php.net/manual/en/mail.configuration.php>
 [2016-11-16 20:49 UTC] php dot net at ii0 dot net
If this particular configuration setting is now only supported in php.ini, that is fine.  

Thank you for the link to that page of doco I obviously never found. And thank you for the idea to wrap ini_set() with an if() that could detect whether or not ini_set() was successful.  

Of course, by the time I finally figured out that ini_set() of sendmail_path was the culprit -- no thanks to the error log -- there was no need for such an if() wrapper.

I think there should have been a note about this behavior change here:
http://php.net/manual/en/mail.configuration.php#ini.sendmail-path
and in the upgrade docs I was relying on:
http://php.net/migration55
http://php.net/migration56
but hey.  I am just happy we don't actually need it to be configured on the fly with ini_set(), and are able to use the same path for everything.

Thanks again!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC