Location: PHPKode > scripts > Send messages via SMTP > send-messages-via-smtp/socktest.php
<?
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";
}
?>
Return current item: Send messages via SMTP