PHP mail() woes

Floyd Arguello floyd.lists at gmail.com
Wed Jun 11 19:30:16 MST 2008


I'm surprised that you don't have errors in your maillog.

Anyway, php mail() opens and closes an smtp socket for each message...
not a big deal unless you're hosting several email accounts on the
site, then you have to consider that smtpd is called for every inbound
message, etc...

So increasing qmail-smtpd max connections might help, but if you
increase it too much you could thrash your server.

Replacing the native php mail might be a better solution. Try this:
http://pear.php.net/package/Mail or find another one.

Floyd


On Wed, Jun 11, 2008 at 6:57 PM,  <fouldragon at aol.com> wrote:
> Looking at the logs for a few of the times it occured:
>
> 13:38:06-- finished spam-assassin processing one message, started
> another, local delivery.
>
> 12:39:34-- Recieved an inbound message from SMTP land
>
> 10:21:12-- A message finished 2 seconds previous, a POP3 connection 4
> seconds later.
>
> There's nothing that looks out of the ordinary.  Maybe the 'sendmail'
> program or whatever part of qmail it maps to hit some internal limit--
> "There are 5 running, don't start a new one?"
>
> -----Original Message-----
> From: Floyd Arguello <floyd.lists at gmail.com>
> To: Main PLUG discussion list <plug-discuss at lists.plug.phoenix.az.us>
> Sent: Wed, 11 Jun 2008 6:41 pm
> Subject: Re: PHP mail() woes
>
>
>
>
>
>
>
>
>
>
> What do your maillogs show?
>
> Floyd
>
>
> On Wed, Jun 11, 2008 at 6:19 PM,  <fouldragon at aol.com> wrote:
>>
>> Oh, to add more details:
>>
>> I tried writing test code which would loop and call mail().
>>
>> Wether I did 20 or 50 iterations, or even running two of the page that
>> did 50 at the same time, to a local address, it still all worked.
>>
>> I also tried sending 50 to "test at invalid.invalid" (since I didn't want
>> it to bother a real host), and it didn't report any errors at the
>> mail() function.
>>
>> So it's obviously not just a "number of messages being sent" thing--
>> the only thing I could see is to somehow monitor all 100+ sites hosted
>> on the server to see if something hits a critical point.
>>
>>
>>
>> -----Original Message-----
>> From: fouldragon at aol.com
>> To: plug-discuss at lists.plug.phoenix.az.us
>> Sent: Wed, 11 Jun 2008 5:44 pm
>> Subject: PHP mail() woes
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Several sites on the VPS I administer send out several "order
>> confirmation" emails when a specific page is hit.
>>
>> Because of the way they run their businesses, it's non-negotiable that
>> between 3 and ~12 messages are sent out on these occurences.
>>
>> The problem is that occasionally--- probably about one in 20 times
> such
>> a page is accessed, the server error logs fill up with:
>>
>> [Wed Jun 11 13:38:06 2008] [error] [client a.b.c.d] PHP Warning:
>> mail() [<a href='function.mail'>function.mail</a>]: Could not execute
>> mail delivery program '/usr/sbin/sendmail -t -i' in
>> /var/www/vhosts/xxxxxxx/httpdocs/feedback.php on line 54, referer:
>> http://xxxxxxxx
>>
>> Since it tries to send a handful of messages at once, they usually
> come
>> in clumps of 5 or 6 messages like this.
>>
>> I tried correlating the times of the errors with resource warnings in
>> Virtuozzo; no dice.
>>
>> I keep hearing that the PHP mail() call is not intended for bulk
>> mailing-- but less than 20 messages at a shot is not bulk as I see it.
>>
>> The only thing I could see is some sort of resource exhaustion... like
>> it can only have xxx mail() calls in the air at once, and it exceeds
>> that limit.
>>
>> The server runs FC6 with Plesk 8.3 on top, so the mail setup is qmail,
>> but it uses xinetd.  I saw a few notes about being able to tweak
>> qmail-smtpd to open more instances, but I'm not even sure that's
>> relevant to the problem (since mail() calls are coming from local).
>>
>> What about replacing /usr/sbin/sendmail -t -i with
>> /var/qmail/bin/qmail-inject - someone suggested this?  Would that have
>> any possible difference?
>>
>> And what's a good way to find out if this will repeat, other than
>> sitting and monitoring the logs for an error?
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>
>>
>>
>>
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>


More information about the PLUG-discuss mailing list