Login   Register  
PHP Classes
elePHPant
Icontem

File: socktest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2006-03-07 20:15
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";
}
?>