On Ubuntu 13.04, not sure of the other Distros.
If you simply uncomment the default:
sendmail_path = "sendmail -t -i"
Your mail() functions will all fail. This is because, you should place the FULL PATH (i.e. /usr/sbin/sendmail -t -i )
The documentation states PHP tries it's best to find the correct sendmail path, but it clearly failed for me.
So, always enter in the FULLPATH to sendmail or you may get unexpected failing results.
As a secondary note: Those that just want to ENFORCE the -f parameter, you can do so in php.ini using:
mail.force_extra_parameters = [email protected]
You can leave the sendmail path commented out, it will still use the defaults (under UNIX -t -i options which if you look them up are very important to have set)....
But, now there is no way to change this, even with the 5th argument of the mail() function. -f is important, because if NOT set, will be set to which ever user the PHP script is running under, and you may not want that.
Also, -f sets the Return-Path: header which is used as the Bounce address, if errors occur, so you can process them. You you can not set Return-Path: in mail() headers for some reason... you could before. Now you have to use the -f option.Конфигурација во време на извршување
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Конфигурација во време на извршување
Референца за `mail.configuration.php` со подобрена типографија и навигација.
Конфигурација во време на извршување
Поведението на овие функции е под влијание на поставките во php.ini.
| Име | Стандардно | Променливо | Дневник на промени |
|---|---|---|---|
| mail.add_x_header | "0" | INI_PERDIR |
|
| mail.mixed_lf_and_crlf | "0" | INI_SYSTEM|INI_PERDIR |
Додадено во PHP 8.2.4 |
| mail.log | NULL | INI_SYSTEM|INI_PERDIR |
|
| mail.force_extra_parameters | NULL | INI_SYSTEM |
|
| SMTP | "localhost" | INI_ALL |
|
| smtp_port | "25" | INI_ALL |
|
| sendmail_from | NULL | INI_ALL |
|
| sendmail_path | "/usr/sbin/sendmail -t -i" | INI_SYSTEM |
Еве кратко објаснување на директивите за конфигурација.
-
mail.add_x_headerbool -
Додади
X-PHP-Originating-Scriptшто ќе го вклучува UID-то на скриптата проследено со името на датотеката. -
mail.logstring -
Патеката до датотека за лог што ќе ги логгира сите mail() повици. Записите во логот вклучуваат целосна патека на скриптата, број на линија,
Toадреса и заглавија. -
mail.mixed_lf_and_crlfbool -
Овозможува враќање на разделувачот на редови за заглавијата на е-пошта и телата на пораките на LF (Line Feed), имитирајќи го несоодветното однесување на PHP 7. Обезбедено е како мерка за компатибилност за одредени несоодветни агенти за пренос на пошта (MTA) што не успеваат правилно да ги обработат CRLF (Carriage Return + Line Feed) како разделувач на редови во заглавијата на е-поштата и содржината на пораката.
-
mail.force_extra_parametersstring -
Присили додавање на наведените параметри што ќе бидат предадени како дополнителни параметри на бинарната датотека sendmail. Овие параметри секогаш ќе ја заменат вредноста на 5-тиот параметар до mail().
Покрај стандардното однесување заINI_SYSTEM, оваа вредност може да се постави и соphp_valuein httpd.conf (но ова не се препорачува). -
SMTPstring -
Се користи само под Windows: име на домаќин или IP адреса на SMTP серверот што PHP треба да го користи за пошта испратена со mail() function.
-
smtp_portint -
Се користи само под Windows: Број на портата за поврзување со серверот наведен со
SMTPпоставката при испраќање пошта со mail(); стандардно е 25. -
sendmail_fromstring -
Која
"From:"адреса на е-пошта треба да се користи во е-пошта испратена директно преку SMTP (само за Windows). Оваа директива исто така ја поставува"Return-Path:"header. -
sendmail_pathstring -
Каде што sendmail програмата може да се најде, обично /usr/sbin/sendmail or /usr/lib/sendmail. configure прави искрен обид да го лоцира ова за вас и да постави стандардно, но ако не успее, можете да го поставите овде.
Системите што не користат sendmail треба да ја постават оваа директива на обвивката/замената на sendmail што ја нуди нивниот систем за пошта, ако има. На пример, » Qmail корисниците обично можат да го постават на /var/qmail/bin/sendmail or /var/qmail/bin/qmail-inject.
qmail-inject не бара никаква опција за правилно обработување на поштата.
Оваа директива работи и под Windows. Ако е поставено, smtp, smtp_port and sendmail_from се игнорираат и се извршува наведената команда.
Белешки од корисници 3 белешки
The documentation should be made clear that sendmail does NOT default to -t -i when using just /usr/sbin/sendmail. You literally need to specify the options.
I know this might seem like a no-brainer but I wasted hours trying to get mail() to work only to discover that the sendmail program is NOT passed -t and -i by default as stipulated in the documentation.If anyone gets this cryptic error message in the PHP error logs:
"sh: -t: command not found"
after upgrading from PHP 5.4, this may be the solution for you.
I upgraded PHP from 5.4 to 5.6 and all our mail() functionality suddenly broke, with no useful error logging.
If this is you, and you've been using ini_set() to set the "sendmail_path" then note that even though it's apparently not mentioned in the upgrade documentation -- or anywhere else I could find on php.net (or a dozen forums) -- you'll now need to go set the sendmail_path in your php.ini file; it is now ignored if you use ini_set() to specify a path to the sendmail binary on the fly.
So, just specify "sendmail_path" in php.ini instead. That's all there is to it -- that fixed all the mail() functionality for us.
Hope this little note saves someone else as much time as I spent troubleshooting and researching. Cheers!