$smtp->host_name="mail.xiaocui.com"; $smtp->localhost="localhost"; $from="webmaster@xiaocui.com"; $to="root@xiaocui.com"; if($smtp->SendMessage( $from, array( $to ), array( "From: $from", "To: $to", "Subject: Testing Manuel Lemos' SMTP class" ), "Hello $to,nnIt is just to let you know that your SMTP class is working just fine.nnBye.n")) echo "Message sent to $to OK.n"; else echo "Cound not send the message to $to.nError: ".$smtp->error."n" ?>
smtp.php
class smtp_class { var $host_name=""; var $host_port=25; var $localhost=""; var $timeout=0; var $error=""; var $debug=1; var $esmtp=1; var $esmtp_host=""; var $esmtp_extensions=array(); var $maximum_piped_recipients=100;
/* private variables - DO NOT ACCESS */
var $state="Disconnected"; var $connection=0; var $pending_recipients=0;
/* Private methods - DO NOT CALL */
Function OutputDebug($message) { echo $message," n"; }
Function GetLine() { for($line="";;) { if(feof($this->connection)) { $this->error="reached the end of stream while reading from socket"; return(0); } if(($data=fgets($this->connection,100))==false) { $this->error="it was not possible to read line from socket"; return(0); } $line.=$data; $length=strlen($line); if($length>=2 && substr($line,$length-2,2)=="rn") { $line=substr($line,0,$length-2); if($this->debug) $this->OutputDebug("< $line"); return($line); } } }
Function PutLine($line) { if($this->debug) $this->OutputDebug("> $line"); if(!fputs($this->connection,"$linern")) { $this->error="it was not possible to write line to socket"; return(0); } return(1); }
Function PutData($data) { if(strlen($data)) { if($this->debug) $this->OutputDebug("> $data"); if(!fputs($this->connection,$data)) { $this->error="it was not possible to write data to socket"; return(0); } } return(1); }
Function VerifyResultLines($code,$responses="") { if(GetType($responses)!="array") $responses=array(); Unset($match_code);