cvs: pear /Net_SMTP SMTP.php /Net_SMTP/docs/examples basic.php

From: Date: Thu, 11 Mar 2004 08:15:34 +0000
Subject: cvs: pear /Net_SMTP SMTP.php /Net_SMTP/docs/examples basic.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-17294@lists.php.net to get a copy of this message
jon Thu Mar 11 03:15:34 2004 EDT Added files: /pear/Net_SMTP/docs/examples basic.php Modified files: /pear/Net_SMTP SMTP.php Log: Adding a simple example script. http://cvs.php.net/diff.php/pear/Net_SMTP/SMTP.php?r1=1.43&r2=1.44&ty=u Index: pear/Net_SMTP/SMTP.php diff -u pear/Net_SMTP/SMTP.php:1.43 pear/Net_SMTP/SMTP.php:1.44 --- pear/Net_SMTP/SMTP.php:1.43 Thu Mar 11 00:50:45 2004 +++ pear/Net_SMTP/SMTP.php Thu Mar 11 03:15:33 2004 @@ -29,6 +29,8 @@ * @author Chuck Hagenbuch <chuck@horde.org> * @author Jon Parise <jon@php.net> * @author Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> + * + * @example basic.php A basic implementation of the Net_SMTP package. */ class Net_SMTP { http://cvs.php.net/co.php/pear/Net_SMTP/docs/examples/basic.php?r=1.1&p=1 Index: pear/Net_SMTP/docs/examples/basic.php +++ pear/Net_SMTP/docs/examples/basic.php <?php require 'Net/SMTP.php'; $host = 'mail.example.com'; $from = 'user@example.com'; $rcpt = array('recipient1@example.com', 'recipient2@example.com'); $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"); } /* 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();

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