Asked  7 Months ago    Answers:  5   Viewed   44 times

I'm trying to figure out why the mail function in PHP fails when called via web browser (i.e. apache), but I can run the same script from the command line using

php -f mailtest.php

This is one of my client's Fedora servers, so I don't grok it completely, but I do have root access should I need to change anything.

from php.ini:

sendmail_path = /usr/sbin/sendmail -t -i

Not sure if this could matter, but /usr/sbin/sendmail is a symlink to /etc/alternatives/mta, which is a symlink back to /usr/sbin/sendmail.sendmail. FWIW the apache user does have permission to run sendmail (tested sendmail directly from the command line).

OS: Fedora Core 7 Linux (kernel 2.6.23.17)  
Apache: 2.2.8  
PHP: 5.2.6

Any help here will be greatly appreciated!

 Answers

25

I found the problem. SELinux was preventing apache from being able to use sendmail. To diagnose, I used

$ sestatus -b | grep sendmail  
httpd_can_sendmail                   off

Then to actually fix the problem:

$ restorecon /usr/sbin/sendmail
$ setsebool -P httpd_can_sendmail 1

Read more about it here.

Wednesday, March 31, 2021
 
revive
answered 7 Months ago
61

Try putting:

putenv("PYTHONIOENCODING=utf-8");

in the script before calling exec(). googler apparently requires the locale or this environment variable to be set.

Wednesday, March 31, 2021
 
njai
answered 7 Months ago
29

It seems like the script is running out of the memory. Magento native UrlRewrite indexer is quite slow and using a lot of memory. If you have 26k products and a lot of categories it might produce a segmentation fault.

You can try alternative Url Rewrite indexer that is using much less memory and takes much less time than core one, because performing all the operations on database level. But it requires privileges for creation and using of stored routines to work properly. Also it is strictly recommended to try it on dev environment first, to see that it will not be broken, since sometimes developers adding invalid records to core_url_rewrite table that breaking some operations.

The extension can be found by the following url: http://www.ecomdev.org/2011/10/08/ecomdev-breaks-magento-speed-limits.html

Saturday, May 29, 2021
 
ojrac
answered 5 Months ago
30

If this is a Red Hat-derived distribution (RHEL, CentOS, Fedora, ScientificLinux) running SELinux (or any non Red Hat derivative using SELinux), the default policy setting at time of this writing is to prohibit Apache from making external connections to other servers or databases. As root, you must enable the following two SELinux booleans. Use the -P option to persist the change across a reboot.

setsebool -P httpd_can_network_connect=1
setsebool -P httpd_can_network_connect_db=1

Note that httpd_can_network_connect may not be necessary. Try it first turning on only httpd_can_network_connect_db.

Tuesday, August 3, 2021
 
Revent
answered 3 Months ago
72

If it is a dedicated server, make sure you have postFix Mail installed (http://www.postfix.org/)

I faced this error today itself as the SMTP server was not available (i assumed it as there by default, but not)

Wednesday, September 1, 2021
 
Terry
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :