cvs: peardoc /en/package/html/html-template-flexy/html-template-flexy bufferedoutputobject.xml
| From: | Alan Knowles | Date: | Thu, 22 Jan 2004 13:29:41 +0000 |
| Subject: | cvs: peardoc /en/package/html/html-template-flexy/html-template-flexy bufferedoutputobject.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-2149@lists.php.net to get a copy of this message | ||
alan_k Thu Jan 22 08:29:41 2004 EDT
Modified files:
/peardoc/en/package/html/html-template-flexy/html-template-flexy
bufferedoutputobject.xml
Log:
actually provide an example that really works!!
http://cvs.php.net/diff.php/peardoc/en/package/html/html-template-flexy/html-template-flexy/bufferedoutputobject.xml?r1=1.6&r2=1.7&ty=u
Index: peardoc/en/package/html/html-template-flexy/html-template-flexy/bufferedoutputobject.xml
diff -u peardoc/en/package/html/html-template-flexy/html-template-flexy/bufferedoutputobject.xml:1.6
peardoc/en/package/html/html-template-flexy/html-template-flexy/bufferedoutputobject.xml:1.7
--- peardoc/en/package/html/html-template-flexy/html-template-flexy/bufferedoutputobject.xml:1.6 Tue
Aug 12 22:31:29 2003
+++ peardoc/en/package/html/html-template-flexy/html-template-flexy/bufferedoutputobject.xml Thu Jan
22 08:29:41 2004
@@ -1,4 +1,4 @@
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<refentry
id="package.html.html-template-flexy.html-template-flexy.bufferedoutputobject">
<refnamediv>
<refname>$flexy->bufferedOutputObject()</refname>
@@ -83,31 +83,46 @@
var $cleartextPassword;
var $email;
- function send_password() {
- $this->generatePassword();
-
- /* use the regex compiler, as it doesnt parse <tags */
- $template = new HTML_Template_Flexy(array('compiler'=>'Regex');
-
- /* compile a text file (email template) */
- $template->compile("Emails/Send_Password.txt");
-
- /* use variables from this object to ouput data. */
- $mailtext = $template->bufferedOutputObject($this);
-
+ function sendEmail($templateFile,$content) {
+
+ $content = is_object($content) ? $content : (object) $content;
+ foreach(get_object_vars($this) as $k=>$v) {
+ $content->$k = $v;
+ }
+ /* use the regex compiler, as it doesnt parse <tags */
+ $template = new HTML_Template_Flexy( array(
+ 'compiler' => 'Regex',
+ 'filters' => array('SimpleTags','Mail'),
+ ));
+
+ /* compile a text file (email template) */
+ $template->compile($templateFile);
+
+ /* use variables from this object to ouput data. */
+ $mailtext = $template->bufferedOutputObject($content);
+ //echo "<PRE>";print_R($mailtext);
+
+ /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
+ require_once 'Mail/mimeDecode.php';
+ require_once 'Mail.php';
+
+ $decoder = new Mail_mimeDecode($mailtext);
+ $parts = $decoder->getSendArray();
+ if (PEAR::isError($parts)) {
+ return $parts;
+
+ }
+ list($recipents,$headers,$body) = $parts;
+
+ $mailOptions = PEAR::getStaticProperty('Mail','options');
+ $mail = Mail::factory("SMTP",$mailOptions);
+
+ return PEAR::isError($mail) ? $mail : $mail->send($recipents,$headers,$body);
- /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
- $decoder = new Mail_mimeDecode($mailtext);
- $parts = $decoder->getSendArray();
- if (PEAR::isError($parts)) {
- echo "PROBLEM: {$parts->message}";
- exit;
- }
- list($recipents,$headers,$body) = $parts;
- $mail = Mail::factory("SMTP",$options);
- $mail->send($recipents,$headers,$body);
- }
+ }
+
+
}
]]>
@@ -120,13 +135,13 @@
<![CDATA[
From: "HTML_Template_Flexy" <html_template_flexy@pear.php.net>
Sender: "HTML_Template_Flexy" <html_template_flexy@pear.php.net>
-To: {email}
+To: {t.email}
Subject: Here is your new password
Content-Type: text/plain; charset=us-ascii
-Dear {name}
+Dear {t.name}
-Your New Password is {cleartextPassword}
+Your New Password is {t.cleartextPassword}
please use it to log into your bank account :)