\n";
fputs($this->fp, $data."\r\n");
$this->recv();
}
function recv(){
$response=fgets($this->fp, 512);
list ($errno, $errmsg) = split (" ", $response);
if ($errno<500){
echo "$response\n
";
}else{
echo "$response\n
";
exit;
}
}
function open($smtpserver,$ti=2){
$this->fp = fsockopen($smtpserver, 25, $errno, $errstr, $ti);
if (!$this->fp){
echo "Error opening $smtpserver
$errstr ($errno).
\n";
exit;
}
$this->recv();
}
function close(){
fclose($this->fp);
}
}
$fun = new funWithSMTP;
// Just starting? Edit these three lines.
// ===============================================
$to = '"Buggs Bunny" ';
$from = '"Elmer Fudd" ';
$mySMTPserver = 'my.workingSMTPserver.com';
// ===============================================
$header.="Date: 27 Jan 2002 15:01:01 EDT\r\n";
$header.="From: $from\r\n";
$header.="To: $to\r\n";
$header.="Subject: This is fun!\r\n";
$header.="Date: Wed, 17 Apr 2002 20:52:23 -0400\r\n";
$header.="Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$header.="Content-Transfer-Encoding: 7bit\r\n";
$header.="X-Priority: 3\r\n";
$separator="\r\n";
$body.="Whats up doc?\r\n";
$body.="Ain't I a little stinker?\r\n";
$terminator=".";
$theEmailText = $header.$separator.$body.$terminator;
$fun->open($mySMTPserver);
$fun->send("HELO looneytunes.com");
$fun->send("MAIL FROM:$from");
$fun->send("RCPT TO:$to");
$fun->send("DATA");
$fun->send($theEmailText);
$fun->send("RSET");
$fun->send("QUIT");
$fun->close();
?>