PHP Classes

File: socktest.php

Recommend this page to a friend!
  Classes of Nic Stevens   Send messages via SMTP   socktest.php   Download  
File: socktest.php
Role: Example script
Content type: text/plain
Description: Test program for sock.php
Class: Send messages via SMTP
Send e-mail messages via SMTP connections.
Author: By
Last change:
Date: 18 years ago
Size: 501 bytes
 

Contents

Class file image Download
<?
include('sock.php');

$cd = array('address' => 'localhost',
       
'port' => 80,
       
'timeout' => 2);

try {
   
$s = new sock($cd);
} catch (
Exception $e) {
    echo
"Error connecting. " . $e->getMessage() . "\n";
    exit;
}
$s->send_data("GET / HTTP/1.0\n\n");
$read = true;
while(
$read) {
    if(!
$s->get_data($data))
    break;

    if(
$data == "")
     
$read = false;
    if(
trim($data) != $data)
      echo
$data;
    else
      echo
"[" . trim($data) . "]\n";
}
?>