X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=inc%2Fclasses%2Fthird_party%2Fphp_mailer%2Fdocs%2Fextending.html;fp=inc%2Fclasses%2Fthird_party%2Fphp_mailer%2Fdocs%2Fextending.html;h=f7c3200afca00007e2ec1e4cbffa09cc1b599b85;hb=01bb590df8ed22731be7451d217ce0455d4e3609;hp=0000000000000000000000000000000000000000;hpb=4e306386bc268b3b3a84ee9101274581d2aa1666;p=core.git diff --git a/inc/classes/third_party/php_mailer/docs/extending.html b/inc/classes/third_party/php_mailer/docs/extending.html new file mode 100644 index 00000000..f7c3200a --- /dev/null +++ b/inc/classes/third_party/php_mailer/docs/extending.html @@ -0,0 +1,148 @@ + +
++ +This demonstrates sending out multiple email messages with binary attachments +from a MySQL database with multipart/alternative support.
+
++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 <font size=\"4\">" . $row["full_name"] . "</font>, <p>"; + $body .= "<i>Your</i> personal photograph to this message.<p>"; + $body .= "Sincerely, <br>"; + $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"] . "<br>"; + + // Clear all addresses and attachments for next loop + $mail->ClearAddresses(); + $mail->ClearAttachments(); +} ++ |
+
+ +
+ +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: + +
+Here's a class that extends the phpmailer class and sets the defaults
+for the particular site:
+PHP include file: mail.inc.php
+
+ +
++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 + } +} + |
+
+ +
++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"; ++ |
+