email.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. ob_start();
  28. bx_import('BxDolAccount');
  29. $oAccount = BxDolAccount::getInstance();
  30. $aAccountInfo = $oAccount ? $oAccount->getInfo() : false;
  31. if (!$aAccountInfo)
  32. return DesignBoxContent("Send Email example", 'Please login first', BX_DB_PADDING_DEF);
  33. echo "<h2>Account info</h2>";
  34. echo "Email: " . $aAccountInfo['email'] . '<br />';
  35. echo "Email Confirmed: " . ($aAccountInfo['email_confirmed'] ? 'yes' : 'no') . '<br />';
  36. echo "Receive site updates: " . ($aAccountInfo['receive_updates'] ? 'yes' : 'no') . '<br />';
  37. echo "Receive site newsletters: " . ($aAccountInfo['receive_news'] ? 'yes' : 'no') . '<br />';
  38. echo "Site emails are sent from: " . getParam('site_email_notify') . '<br />';
  39. $a = array (
  40. 'sys' => array (
  41. 'title' => "Send me system email",
  42. 'type' => BX_EMAIL_SYSTEM,
  43. 'subj' => 'System Email',
  44. 'body' => 'This is system email <br /> {unsubscribe}',
  45. ),
  46. 'notif' => array (
  47. 'title' => "Send me notification",
  48. 'type' => BX_EMAIL_NOTIFY,
  49. 'subj' => 'Notification Email',
  50. 'body' => 'This is notification email<br /> {unsubscribe}',
  51. ),
  52. 'mass' => array (
  53. 'title' => "Send me bulk email",
  54. 'type' => BX_EMAIL_MASS,
  55. 'subj' => 'Bulk Email',
  56. 'body' => 'This is bulk email<br /> {unsubscribe}',
  57. ),
  58. );
  59. $sSendMail = bx_get('send');
  60. if ($sSendMail && isset($a[$sSendMail])) {
  61. echo "<h2>Send Email Result</h2>";
  62. $r = $a[$sSendMail];
  63. if (sendMail($aAccountInfo['email'], $r['subj'], $r['body'], 0, array(), $r['type']))
  64. echo MsgBox($r['subj'] . ' - successfully sent');
  65. else
  66. echo MsgBox($r['subj'] . ' - sent failed');
  67. }
  68. echo "<h2>Send email</h2>";
  69. foreach ($a as $k => $r) {
  70. echo '<a href="samples/email.php?send=' . $k . '">' . $r['title'] . '</a><br />';
  71. }
  72. return DesignBoxContent("Send Email Example", ob_get_clean(), BX_DB_PADDING_DEF);
  73. }
  74. /** @} */