Detect mail() QUOTA exceeded during send?


#1

Is there a special way to detect “mail quota exceeded” (due to exceeding 200 messages per hour) messages in PHP?

if I just assigned the result of mail() to $result and did
if(!$result)echo(“mail failed”);
Would that catch an exceeded Quota situation?

I’d test it, but it is hard and VERY slow to troubleshoot things that need hourly testings.


#2

[quote]Is there a special way to detect “mail quota exceeded” (due to exceeding 200 messages per hour) messages in PHP?

if I just assigned the result of mail() to $result and did
if(!$result)echo(“mail failed”);
Would that catch an exceeded Quota situation?[/quote]
Why would you want to do that? It would seem to me that you should be setting up logic and tests regulate the # of emails sent over time, and stop/delay/suspend sending email at times in order to stay within quota (before exceeding quota). :wink:

–rlparker


#3

I am. But say I was writing a mail queueing system, I would need to know if the mails were sent successfully before setting then as “sent” in my queue database. because it is possible (very) there is some script on my system which is not tied in to the queue and causing things to be out of whack!

Registration emails, lost password, all sorts of things like that which are parts of other stuff that I have not the time to integrate into my queue, which is mainly only for newsletters.


#4

I understand. That is true, but I think the trick there is to either tie your scripts into the queue management or (like many do) allow yourself plenty of buffer room by setting your queue to be significantly less than your quota (so that your application that is queuing plus your other email stay beneath quota).

I’m not trying to dodge your question, but DreamHost assesses escalating penalties for repeatedly going over quota. A system like you describe would not kick in until the quota had been exceeded, which means if you used it heavily, you will be repeatedly over quota, and that can effect your ability to continue to send mail :wink:

–rlparker


#5

Well my cron is every ten minutes and sends 25 (150 per hour), So if I can detect the Quota exceeded I can avoid losing 25 messages every 10 minutes until the 51+ excess is sorted out. Otherwise if the Quoata goes undeteced it is likely to keep kicking in for a while I think.


#6

All that is true, but while you won’t “lose the messages”, you’ll eventually lose your email sending privs for continually exceeding your quota.

The trick is to NOT exceed quota; rather than reporting you *have exceeded quota" and then throttling, throttle before you break exceed quota. :wink:

–rlparker