Source for file 11.php

Documentation is available at 11.php

  1. <?php
  2. /*
  3. * This file is part of Sylar.
  4. *
  5. * Sylar is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Sylar is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with Sylar. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * @copyright Copyright Sylar Development Team
  19. * @license http://www.gnu.org/licenses/ GNU Public License V2.0
  20. * @see https://launchpad.net/sylar/
  21. * @see http://www.giano-solutions.com
  22. */
  23.  
  24. /**
  25. * Example Sylar File
  26. * Some files that shows how sylar works
  27. *
  28. * @package Sylar
  29. * @version 1.0
  30. * @since 02-2008
  31. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  32. * @copyright Sylar Development Team
  33. */
  34.  
  35. #
  36. # Include the bas Application settings
  37. #
  38.  
  39. require_once 'config/appConfig.php';
  40.  
  41. import('sylar.common.communication.Mail');
  42. import('sylar.presentation.html.HtmlPage');
  43.  
  44.  
  45. try{
  46. $txt = "";
  47.  
  48. // New mail in HTML
  49. $ml = new Sylar_Mail("html", "sender@sylarexample.org");
  50. // List of Recipients
  51. $ml->setSend_To( array("Mike"=>"Recipient_1@sylarexample.org", "John"=>"Recipient_2@sylarexample.org") );
  52.  
  53. // List of Cc Recipients
  54. $ml->setSend_CC( array("Mike"=>"Recipient_CC_1@sylarexample.org") );
  55.  
  56. // List of Bcc Recipients
  57. $ml->setSend_BCC( array("Mike"=>"Recipient_BCC_1@sylarexample.org", "John"=>"Recipient_BCC_2@sylarexample.org") );
  58.  
  59. // email HTML Body
  60. $mailBody = "<html><body>".
  61. "<i>Hello</i> this is my first <b>mail</b> with sylar Framework".
  62. "<br><br><hr><br><br>".
  63. "<table border='2'><tr><td>Cell 1</td><td>Cell 2</td></tr></table>".
  64. "</body></html>";
  65.  
  66. $mailObject = "My first HTML Mail with Sylar";
  67. // uncomment when email address in the lists are real
  68. //
  69. // $ml->send($mailObject, $mailBody, APP_DEFAULT_CHARSET);
  70. // test to validate email address method. Modify the address to test the method
  71. $email = "m.green@sylarexample.org";
  72. if($ml->validateAddress($email)){
  73. $txt .= "<br><br>{$email} is OK!";
  74. }else{
  75. $txt .= "<br><br>{$email} is NOT a valid email address!";
  76. }
  77. // Link to next example page
  78. $txt .= "<br><br><br><br><a href='11.php'>Mail sender example &raquo;</a>";
  79. // Prepare Head and Body
  80. $oHH = new Sylar_HtmlHead("Giano Email Test");
  81. $oHH->addMetaTag("text/html; charset=".APP_DEFAULT_CHARSET, null, "content-type");
  82.  
  83. // prepare Body
  84. $oHB = new Sylar_HtmlBody();
  85.  
  86. // Create a DIV
  87. $div = new Sylar_HtmlDiv("test");
  88. // add div content
  89. $div->appendContent($txt);
  90. // append div in the body
  91. $oHB->addDiv($div);
  92. // Then Push into the page Object
  93. $oHP = new Sylar_HtmlPage();
  94. $oHP->setPageHead($oHH);
  95. $oHP->setPageBody($oHB);
  96. // render Html Page
  97. $oHP->show();
  98.  
  99. } catch (ExceptionInSylar $ex){
  100. echo $ex->getMessage();
  101. }
  102.  
  103.  
  104. ?>

Documentation generated on Thu, 24 Apr 2008 16:14:13 +0200 by phpDocumentor 1.3.0RC3