php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28748 mail() resource problem
Submitted: 2004-06-11 23:40 UTC Modified: 2004-06-14 19:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: karthur at kzoo dot edu Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.6 OS: Solaris 8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: karthur at kzoo dot edu
New email:
PHP Version: OS:

 

 [2004-06-11 23:40 UTC] karthur at kzoo dot edu
Description:
------------
mail() stops working a few minutes after Sunone 6 web server starts, which makes this look like a resource problem...

Config line:  "./configure --with-mysql=/usr/local/mysql --with-nsapi=/home/netscape/servers --enable-track-vars --enable-libgcc --with-ldap"

Note that mail() does work briefly after web server is restarted so it doesn't seem to be a configuration problem.

Reproduce code:
---------------
<?php
 mail("karthur@kzoo.edu", "Test Subject", "Test Body");
?>

Expected result:
----------------
expect to receive an email

Actual result:
--------------
no email received

I get no php or system errors but the following error shows up in the IPlanet logs:

"trying to GET /is/sys
net/test/email.php, php4_execute reports: PHP Warning:  mail(): Could not execute
mail delivery program '/usr/lib/sendmail -t'"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-12 19:07 UTC] karthur at kzoo dot edu
Upon further searching this sounds like bug report 25195 
which had no solution given.  Any chance someone has 
discovered a work-around for this?
 [2004-06-12 22:31 UTC] thetaphi@php.net
This problem is well known and a problem of Solaris in all versions. For PHP 4.3.4 we ported a lot of code from PHP5 back to eliminate fopen(),... Scripts now start without any problems (until PHP 4.3.3 even this could fail). But there are still a lot of extensions that use stdio functions.

A solution would be to write a temporary file with the complete mail (headers and text) and then execute: exec("/bin/sh -c \"/usr/lib/sendmail -t </tmp/mail.txt\"").
 [2004-06-14 15:44 UTC] karthur at kzoo dot edu
Thanks for the quick feedback.  However, we have a similar problem with exec so the suggested work-around won't help.

I'm going to try to rewrite mail.c to use sfio from AT&T.  The downside is that I'll then have to reimplement that fix everytime we upgrade php.  I can share the code I come up with if anyone is interested.  If it does work, then I'll try to look more into the exec function as well.

If it doesn't work then another work-around I thought of is to have php write the email to a file and then have a cron-scheduled system script pass the file off to sendmail.
 [2004-06-14 18:39 UTC] papercrane at reversefold dot com
If you continue to have this problem, you may want to look into a package which implements mailing in PHP code, such as:

http://pear.php.net/package/Mail
 [2004-06-14 19:31 UTC] karthur at kzoo dot edu
Here's a solution that appears to work for us so far.  It might be nice if the php developers would consider a --with-sfio parameter in configure that took care of this.  Our exec command is still broken so I'll probably have to do this same type of thing for that.

1.  install sfio from AT*T
2.  setenv LIBS "-L/usr/local/lib/sfio -lsfio"
3.  modify ext/standard/mail.c
4.  modify /usr/local/include/sfio/sfio.h so references to other sfio header files are absolute paths (if I use -I/usr/local/include/sfio to find the files it produces errors for files other than mail.c)
5.  run configure and compile as normal

here's a diff or my code and the original mail.c:

diff mail.c mail.c.orig
23c23
< #include </usr/local/include/sfio/sfio.h>
---
> #include <stdio.h>
177c177
<         Sfio_t *sendmail=NULL;
---
>       FILE *sendmail;
215c215
<         sendmail = sfpopen(sendmail, sendmail_cmd, "w");
---
>       sendmail = popen(sendmail_cmd, "w");
224c224
<                       sfclose(sendmail);
---
>                       pclose(sendmail);
228,229c228,229
<               sfprintf(sendmail, "To: %s\n", to);
<               sfprintf(sendmail, "Subject: %s\n", subject);
---
>               fprintf(sendmail, "To: %s\n", to);
>               fprintf(sendmail, "Subject: %s\n", subject);
231c231
<                       sfprintf(sendmail, "%s\n", headers);
---
>                       fprintf(sendmail, "%s\n", headers);
233,234c233,234
<               sfprintf(sendmail, "\n%s\n", message);
<               ret = sfclose(sendmail);
---
>               fprintf(sendmail, "\n%s\n", message);
>               ret = pclose(sendmail);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 29 07:01:31 2024 UTC