tags:

views:

67

answers:

3

Bit of a long shot, but is it possible to count how many emails a given SMTP account has sent in an hour?

Say [email protected] sends emails via Thunderbird and a PHP script.

Can that PHP script first check somehow how many emails have been sent that hour?

Obviously the PHP script can easilly keep a tally of how many emails it sends, but no way of knowing if John has been sending too many from his email client, or another script...

Many thanks.

+1  A: 

If SMTP server does not have such statistics, then it is not possible to get the number.

Why are you asking, is there some authority that counts e-mails and says No when you reach the limit? If so, then ask that authority.

Messa
A: 

You can try to analyze /var/log/mail.log file. Usually it keeps all the info you need. For example, you can write a script, that gathers all data from mail.log, analyzes it, and puts it into some database table. This script could be run by cron every hour, or so (depending when you need the info)

Silver Light
A: 

Short answer is no (there's a lot wrong with Konstantin's reply, but criticizing it probably isn't going to help). What is the problem you are trying to solve and why do you think a PHP script is the right solution?

C.

symcbean
The problem is a PHP script that already exists running every hour and occasional finding that the email allowance has been used up by human users within the office.They want the auto emails to come from the same accounts that they normally use to contact their clients -- hence why emails from both the script and actual users are counting towards the same limit.
MQA
So stop analyzing the problem and fix it by running your own smart relay to queue messages when the MTA you are currently using refuses to send - or switch to a different MTA.
symcbean