PHP Classes

File: funWithSMTP.php

Recommend this page to a friend!
  Classes of Pierre Marceau  >  funWithSMTP  >  funWithSMTP.php  >  Download  
File: funWithSMTP.php
Role: ???
Content type: text/plain
Description: The whole thing
Class: funWithSMTP
Talk directly to an SMTP server to send e-mail.
Author: By
Last change:
Date: 20 years ago
Size: 1,841 bytes


Class file image Download

class funWithSMTP{

var $fp;

function send($data){
  echo nl2br($data)."<br>\n";
  fputs($this->fp, $data."\r\n");

function recv(){
  $response=fgets($this->fp, 512);
  list ($errno, $errmsg) = split (" ", $response);
  if ($errno<500){
    echo "<font color=\"blue\">$response</font>\n<br>";
    echo "<font color=\"red\">$response</font>\n<br>";

function open($smtpserver,$ti=2){
  $this->fp = fsockopen($smtpserver, 25, $errno, $errstr, $ti);
  if (!$this->fp){
    echo "<b>Error opening $smtpserver</b><br><font color=\"red\">$errstr ($errno).</font><hr>\n";

function close(){

$fun = new funWithSMTP;

// Just starting? Edit these three lines.
// ===============================================
$to             =   '"Buggs Bunny" <>';
$from           =   '"Elmer Fudd" <>';
$mySMTPserver   =   '';
// ===============================================

$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";


$body.="Whats up doc?\r\n";
$body.="Ain't I a little stinker?\r\n";


$theEmailText = $header.$separator.$body.$terminator;

$fun->send("MAIL FROM:$from");
$fun->send("RCPT TO:$to");
For more information send a message to info at phpclasses dot org.