PHP Classes

File: smtpstatus.inc.php

Recommend this page to a friend!
  Packages of Pierre Marceau   smtpStatus   smtpstatus.inc.php   Download  
File: smtpstatus.inc.php
Role: Class source
Content type: text/plain
Description: The class file.
Class: smtpStatus
Check the status of multiple SMTP servers.
Author: By
Last change:
Date: 23 years ago
Size: 1,934 bytes
 

Contents

Class file image Download
<?php

/*

Apr 8, 2003.

==============================================================
This script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS  FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

This  file  is  copyright (c)2003  Pierre Marceau  all  rights
reserved.  You may freely use and redistribute under the terms
of the GNU General Public License.
--------------------------------------------------------------
        smtpstatus - http://www.skynet.ca/~pierre/
==============================================================
*/

class smtpstatus{

  function getmicrotime(){ 
    list($usec, $sec) = explode(" ",microtime()); 
    return ((float)$usec + (float)$sec); 
  } 

  function cm($smtpserver,$ti=2){
    $start=$this->getmicrotime();
    $fp = fsockopen($smtpserver, 25, $errno, $errstr, $ti);
    $end=$this->getmicrotime();
    $stoptime="Mail server response time was <b>".number_format($end-$start,4)."</b> seconds.";
    if (!$fp){
      echo "<b>$smtpserver</b><br><font color=\"red\">$errstr ($errno).</font><br>$stoptime<br><hr>\n";
      return 0;
    } 
    $retval = fgets($fp, 512);
    fputs($fp, "QUIT\r\n");
    fgets($fp, 512);
    fclose($fp);
    echo "<b>$smtpserver</b> <i>responded with:</i><br>$retval<br>$stoptime<br>\n<hr>\n";
  }

  function header($mytitle="My Company Inc."){
    echo "<html>\n";
    echo "<head>\n";
    echo "<title>$mytitle</title>\n";
    echo "</head>\n";
    echo "<body>\n";
    echo "<H1>$mytitle</H1>\n";
    echo date("l dS of F Y h:i:s A")."\n<br>\n<br>\n";
    echo "If a server did not respond, maybe it was busy, please click refresh to try again.\n<br>\n<br>\n";
    echo "<hr>\n";
  }

  function footer(){
    echo "--<br>\nEnd of report.\n</body>\n</html>\n";
  }
}
?>