Possible to count number of messages sent via SMTP in PHP?
Bit of a long shot, but is it possible to count how many emails a g开发者_Python百科iven SMTP account has sent in an hour?
Say john@example.com 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.
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.
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)
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.
精彩评论