Get email quota status in PHP

Hi.

As we know, a free account can send up to 50 emails (using PHP’s mail() function) per day.

On my site, I have a contact form where people can enter their message and the form data is sent to my email address from the backend.

When my daily quota (of 50 emails) is exhausted, no more emails will be sent.

Is there any way to find out how many emails I have left for the day, or whether 00wehbost’s systems sent the email, in PHP so that I can show an appropriate message to my visitors?? It would be a great help if someone could tell me how.

Thanks.
~Progyadeep.

https://www.000webhost.com/members/website/progyadeep/stats

There is also http://www.foxyform.com/ and https://docs.google.com/forms/u/0/ which should escape the need for the limit

1 Like

I need a way to get that data programmatically in PHP so the script can echo an appropriate message.

Not possible on free services.

Foxyform is a good solution. Also, thanks for pointing out the fact that what I am trying to achieve is not possible on free services.

1 Like

I wrote a script that will keep a count of the number of emails that have been sent and won’t send further emails when the threshold is reached. It’ll be reset when a new day has come.

$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['msg'];
    
$log = explode("\n", file_get_contents("log.txt"));
if($log[1] < "15"){
    mail("me@smtp.com", "via website", "FROM: ".$name." (".$email.")\n\n".$msg);
    file_put_contents("log.txt", $log[0]."\n".($log[1]+1));
    echo "OK";
}
else if($log[0] != date("d-m-Y")){
    mail("me@smtp.com", "via website", "FROM: ".$name." (".$email.")\n\n".$msg);
    file_put_contents("log.txt", $log[0]."\n".($log[1]+1));
    echo "OK";
}
else{
    echo "Please try again tomorrow.\n\nSERVER TIME: ".date("d-m-Y h:i:s")." ~ UTC-12:00";
}

NOTE: There is a huge timezone issue. The timezone that the 000WH servers follow and what my PHP script follows are probably different, and this script is only usable as I have limited the number of emails to 15 for my own convenience.

2 Likes