cvs: pear /Net_SMTP/docs guide.txt

From: Date: Thu, 11 Mar 2004 08:15:46 +0000
Subject: cvs: pear /Net_SMTP/docs guide.txt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-17295@lists.php.net to get a copy of this message
jon Thu Mar 11 03:15:46 2004 EDT Modified files: /pear/Net_SMTP/docs guide.txt Log: Updating the example in the users guide. http://cvs.php.net/diff.php/pear/Net_SMTP/docs/guide.txt?r1=1.3&r2=1.4&ty=u Index: pear/Net_SMTP/docs/guide.txt diff -u pear/Net_SMTP/docs/guide.txt:1.3 pear/Net_SMTP/docs/guide.txt:1.4 --- pear/Net_SMTP/docs/guide.txt:1.3 Thu Oct 23 00:11:47 2003 +++ pear/Net_SMTP/docs/guide.txt Thu Mar 11 03:15:46 2004 @@ -8,8 +8,8 @@ :Author: Jon Parise :Contact: jon@php.net -:Date: $Date: 2003/10/23 04:11:47 $ -:Revision: $Revision: 1.3 $ +:Date: $Date: 2004/03/11 08:15:46 $ +:Revision: $Revision: 1.4 $ .. contents:: Table of Contents .. section-numbering:: @@ -153,7 +153,7 @@ The following script demonstrates how a simple email message can be sent using the Net_SMTP package:: - require 'SMTP.php'; + require 'Net/SMTP.php'; $host = 'mail.example.com'; $from = 'user@example.com'; @@ -161,29 +161,34 @@ $subj = "Subject: Test Message\n"; $body = "Body Line 1\nBody Line 2"; + /* Create a new Net_SMTP object. */ if (! ($smtp = new Net_SMTP($host))) { die("Unable to instantiate Net_SMTP object\n"); } + /* Connect to the SMTP server. */ if (PEAR::isError($e = $smtp->connect())) { die($e->getMessage() . "\n"); } + /* Send the 'MAIL FROM:' SMTP command. */ if (PEAR::isError($smtp->mailFrom($from))) { die("Unable to set sender to <$from>\n"); } - foreach($rcpt as $recipient) { - if (PEAR::isError($res = $smtp->rcptTo($recipient))) { - die("Unable to add recipient <$recipient>: " . $res->getMessage() . "\n" - ); + /* Address the message to each of the recipients. */ + foreach ($rcpt as $to) { + if (PEAR::isError($res = $smtp->rcptTo($to))) { + die("Unable to add recipient <$to>: " . $res->getMessage() . "\n"); } } + /* Set the body of the message. */ if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) { die("Unable to send data\n"); } + /* Disconnect from the SMTP server. */ $smtp->disconnect(); .. _PEAR_Error: http://pear.php.net/manual/en/core.pear.pear-error.php

« previous php.pear.cvs (#17295) next »