email.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Samples
  7. * @{
  8. */
  9. /**
  10. * @page samples
  11. * @section email Send Email
  12. */
  13. $aPathInfo = pathinfo(__FILE__);
  14. require_once ($aPathInfo['dirname'] . '/../inc/header.inc.php');
  15. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  16. bx_import('BxDolLanguages');
  17. bx_import('BxTemplFunctions');
  18. $oTemplate = BxDolTemplate::getInstance();
  19. $oTemplate->setPageNameIndex (BX_PAGE_DEFAULT);
  20. $oTemplate->setPageHeader ("Send Email Example");
  21. $oTemplate->setPageContent ('page_main_code', PageCompMainCode());
  22. $oTemplate->getPageCode();
  23. /**
  24. * page code function
  25. */
  26. function PageCompMainCode()
  27. {
  28. ob_start();
  29. bx_import('BxDolAccount');
  30. $oAccount = BxDolAccount::getInstance();
  31. $aAccountInfo = $oAccount ? $oAccount->getInfo() : false;
  32. if (!$aAccountInfo)
  33. return DesignBoxContent("Send Email example", 'Please login first', BX_DB_PADDING_DEF);
  34. echo "<h2>Account info</h2>";
  35. echo "Email: " . $aAccountInfo['email'] . '<br />';
  36. echo "Email Confirmed: " . ($aAccountInfo['email_confirmed'] ? 'yes' : 'no') . '<br />';
  37. echo "Receive site updates: " . ($aAccountInfo['receive_updates'] ? 'yes' : 'no') . '<br />';
  38. echo "Receive site newsletters: " . ($aAccountInfo['receive_news'] ? 'yes' : 'no') . '<br />';
  39. echo "Site emails are sent from: " . getParam('site_email_notify') . '<br />';
  40. $a = array (
  41. 'sys' => array (
  42. 'title' => "Send me system email",
  43. 'type' => BX_EMAIL_SYSTEM,
  44. 'subj' => 'System Email',
  45. 'body' => 'This is system email <br /> {unsubscribe}',
  46. ),
  47. 'notif' => array (
  48. 'title' => "Send me notification",
  49. 'type' => BX_EMAIL_NOTIFY,
  50. 'subj' => 'Notification Email',
  51. 'body' => 'This is notification email<br /> {unsubscribe}',
  52. ),
  53. 'mass' => array (
  54. 'title' => "Send me bulk email",
  55. 'type' => BX_EMAIL_MASS,
  56. 'subj' => 'Bulk Email',
  57. 'body' => 'This is bulk email<br /> {unsubscribe}',
  58. ),
  59. );
  60. $sSendMail = bx_get('send');
  61. if ($sSendMail && isset($a[$sSendMail])) {
  62. echo "<h2>Send Email Result</h2>";
  63. $r = $a[$sSendMail];
  64. if (sendMail($aAccountInfo['email'], $r['subj'], $r['body'], 0, array(), $r['type']))
  65. echo MsgBox($r['subj'] . ' - successfully sent');
  66. else
  67. echo MsgBox($r['subj'] . ' - sent failed');
  68. }
  69. echo "<h2>Send email</h2>";
  70. foreach ($a as $k => $r) {
  71. echo '<a href="samples/email.php?send=' . $k . '">' . $r['title'] . '</a><br />';
  72. }
  73. return DesignBoxContent("Send Email Example", ob_get_clean(), BX_DB_PADDING_DEF);
  74. }
  75. /** @} */