eol-style set #3
[core.git] / inc / classes / third_party / php_mailer / docs / extending.html
index f7c3200afca00007e2ec1e4cbffa09cc1b599b85..310f97a3bfd547ea12691fd1f54ddf01ea91b030 100644 (file)
-<html>\r
-<head>\r
-<title>Examples using phpmailer</title>\r
-</head>\r
-\r
-<body bgcolor="#FFFFFF">\r
-\r
-<h2>Examples using phpmailer</h2>\r
-\r
-<h3>1. Advanced Example</h3>\r
-<p>\r
-\r
-This demonstrates sending out multiple email messages with binary attachments\r
-from a MySQL database with multipart/alternative support.<p>\r
-<table cellpadding="4" border="1" width="80%">\r
-<tr>\r
-<td bgcolor="#CCCCCC">\r
-<pre>\r
-require("class.phpmailer.php");\r
-\r
-$mail = new phpmailer();\r
-\r
-$mail->From     = "list@example.com";\r
-$mail->FromName = "List manager";\r
-$mail->Host     = "smtp1.example.com;smtp2.example.com";\r
-$mail->Mailer   = "smtp";\r
-\r
-@MYSQL_CONNECT("localhost","root","password");\r
-@mysql_select_db("my_company");\r
-$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";\r
-$result = @MYSQL_QUERY($query);\r
-\r
-while ($row = mysql_fetch_array ($result))\r
-{\r
-    // HTML body\r
-    $body  = "Hello &lt;font size=\"4\"&gt;" . $row["full_name"] . "&lt;/font&gt;, &lt;p&gt;";\r
-    $body .= "&lt;i&gt;Your&lt;/i&gt; personal photograph to this message.&lt;p&gt;";\r
-    $body .= "Sincerely, &lt;br&gt;";\r
-    $body .= "phpmailer List manager";\r
-\r
-    // Plain text body (for mail clients that cannot read HTML)\r
-    $text_body  = "Hello " . $row["full_name"] . ", \n\n";\r
-    $text_body .= "Your personal photograph to this message.\n\n";\r
-    $text_body .= "Sincerely, \n";\r
-    $text_body .= "phpmailer List manager";\r
-\r
-    $mail->Body    = $body;\r
-    $mail->AltBody = $text_body;\r
-    $mail->AddAddress($row["email"], $row["full_name"]);\r
-    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");\r
-\r
-    if(!$mail->Send())\r
-        echo "There has been a mail error sending to " . $row["email"] . "&lt;br&gt;";\r
-\r
-    // Clear all addresses and attachments for next loop\r
-    $mail->ClearAddresses();\r
-    $mail->ClearAttachments();\r
-}\r
-</pre>\r
-</td>\r
-</tr>\r
-</table>\r
-<p>\r
-\r
-<h3>2. Extending phpmailer</h3>\r
-<p>\r
-\r
-Extending classes with inheritance is one of the most\r
-powerful features of object-oriented\r
-programming.  It allows you to make changes to the\r
-original class for your\r
-own personal use without hacking the original\r
-classes.  Plus, it is very\r
-easy to do. I've provided an example:\r
-\r
-<p>\r
-Here's a class that extends the phpmailer class and sets the defaults\r
-for the particular site:<br>\r
-PHP include file: <b>mail.inc.php</b>\r
-<p>\r
-\r
-<table cellpadding="4" border="1" width="80%">\r
-<tr>\r
-<td bgcolor="#CCCCCC">\r
-<pre>\r
-require("class.phpmailer.php");\r
-\r
-class my_phpmailer extends phpmailer {\r
-    // Set default variables for all new objects\r
-    var $From     = "from@example.com";\r
-    var $FromName = "Mailer";\r
-    var $Host     = "smtp1.example.com;smtp2.example.com";\r
-    var $Mailer   = "smtp";                         // Alternative to IsSMTP()\r
-    var $WordWrap = 75;\r
-\r
-    // Replace the default error_handler\r
-    function error_handler($msg) {\r
-        print("My Site Error");\r
-        print("Description:");\r
-        printf("%s", $msg);\r
-        exit;\r
-    }\r
-\r
-    // Create an additional function\r
-    function do_something($something) {\r
-        // Place your new code here\r
-    }\r
-}\r
-</td>\r
-</tr>\r
-</table>\r
-<br>\r
-\r
-Now here's a normal PHP page in the site, which will have all the defaults set\r
-above:<br>\r
-Normal PHP file: <b>mail_test.php</b>\r
-<p>\r
-\r
-<table cellpadding="4" border="1" width="80%">\r
-<tr>\r
-<td bgcolor="#CCCCCC">\r
-<pre>\r
-require("mail.inc.php");\r
-\r
-// Instantiate your new class\r
-$mail = new my_phpmailer;\r
-\r
-// Now you only need to add the necessary stuff\r
-$mail->AddAddress("josh@example.com", "Josh Adams");\r
-$mail->Subject = "Here is the subject";\r
-$mail->Body    = "This is the message body";\r
-$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name\r
-\r
-if(!$mail->Send())\r
-{\r
-   echo "There was an error sending the message";\r
-   exit;\r
-}\r
-\r
-echo "Message was sent successfully";\r
-</pre>\r
-</td>\r
-</tr>\r
-</table>\r
-</p>\r
-\r
-</body>\r
-</html>\r
+<html>
+<head>
+<title>Examples using phpmailer</title>
+</head>
+
+<body bgcolor="#FFFFFF">
+
+<h2>Examples using phpmailer</h2>
+
+<h3>1. Advanced Example</h3>
+<p>
+
+This demonstrates sending out multiple email messages with binary attachments
+from a MySQL database with multipart/alternative support.<p>
+<table cellpadding="4" border="1" width="80%">
+<tr>
+<td bgcolor="#CCCCCC">
+<pre>
+require("class.phpmailer.php");
+
+$mail = new phpmailer();
+
+$mail->From     = "list@example.com";
+$mail->FromName = "List manager";
+$mail->Host     = "smtp1.example.com;smtp2.example.com";
+$mail->Mailer   = "smtp";
+
+@MYSQL_CONNECT("localhost","root","password");
+@mysql_select_db("my_company");
+$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
+$result = @MYSQL_QUERY($query);
+
+while ($row = mysql_fetch_array ($result))
+{
+    // HTML body
+    $body  = "Hello &lt;font size=\"4\"&gt;" . $row["full_name"] . "&lt;/font&gt;, &lt;p&gt;";
+    $body .= "&lt;i&gt;Your&lt;/i&gt; personal photograph to this message.&lt;p&gt;";
+    $body .= "Sincerely, &lt;br&gt;";
+    $body .= "phpmailer List manager";
+
+    // Plain text body (for mail clients that cannot read HTML)
+    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
+    $text_body .= "Your personal photograph to this message.\n\n";
+    $text_body .= "Sincerely, \n";
+    $text_body .= "phpmailer List manager";
+
+    $mail->Body    = $body;
+    $mail->AltBody = $text_body;
+    $mail->AddAddress($row["email"], $row["full_name"]);
+    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
+
+    if(!$mail->Send())
+        echo "There has been a mail error sending to " . $row["email"] . "&lt;br&gt;";
+
+    // Clear all addresses and attachments for next loop
+    $mail->ClearAddresses();
+    $mail->ClearAttachments();
+}
+</pre>
+</td>
+</tr>
+</table>
+<p>
+
+<h3>2. Extending phpmailer</h3>
+<p>
+
+Extending classes with inheritance is one of the most
+powerful features of object-oriented
+programming.  It allows you to make changes to the
+original class for your
+own personal use without hacking the original
+classes.  Plus, it is very
+easy to do. I've provided an example:
+
+<p>
+Here's a class that extends the phpmailer class and sets the defaults
+for the particular site:<br>
+PHP include file: <b>mail.inc.php</b>
+<p>
+
+<table cellpadding="4" border="1" width="80%">
+<tr>
+<td bgcolor="#CCCCCC">
+<pre>
+require("class.phpmailer.php");
+
+class my_phpmailer extends phpmailer {
+    // Set default variables for all new objects
+    var $From     = "from@example.com";
+    var $FromName = "Mailer";
+    var $Host     = "smtp1.example.com;smtp2.example.com";
+    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
+    var $WordWrap = 75;
+
+    // Replace the default error_handler
+    function error_handler($msg) {
+        print("My Site Error");
+        print("Description:");
+        printf("%s", $msg);
+        exit;
+    }
+
+    // Create an additional function
+    function do_something($something) {
+        // Place your new code here
+    }
+}
+</td>
+</tr>
+</table>
+<br>
+
+Now here's a normal PHP page in the site, which will have all the defaults set
+above:<br>
+Normal PHP file: <b>mail_test.php</b>
+<p>
+
+<table cellpadding="4" border="1" width="80%">
+<tr>
+<td bgcolor="#CCCCCC">
+<pre>
+require("mail.inc.php");
+
+// Instantiate your new class
+$mail = new my_phpmailer;
+
+// Now you only need to add the necessary stuff
+$mail->AddAddress("josh@example.com", "Josh Adams");
+$mail->Subject = "Here is the subject";
+$mail->Body    = "This is the message body";
+$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
+
+if(!$mail->Send())
+{
+   echo "There was an error sending the message";
+   exit;
+}
+
+echo "Message was sent successfully";
+</pre>
+</td>
+</tr>
+</table>
+</p>
+
+</body>
+</html>