BxDolQueueEmail.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolQueueEmail extends BxDolQueue implements iBxDolSingleton
  10. {
  11. protected function __construct()
  12. {
  13. parent::__construct();
  14. $this->_oQuery = new BxDolQueueEmailQuery();
  15. }
  16. /**
  17. * Get singleton instance of the class
  18. */
  19. static function getInstance()
  20. {
  21. if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
  22. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolQueueEmail();
  23. return $GLOBALS['bxDolClasses'][__CLASS__];
  24. }
  25. /**
  26. * Add message to mail queue
  27. *
  28. * @param string $sEmail - recipient email
  29. * @param string $sSubject - message subject
  30. * @param string $sBody - message body
  31. * @return true on success, false on error
  32. */
  33. public function add($sEmail, $sSubject, $sBody, $sHeaders = '', $sParams = '')
  34. {
  35. return (int)$this->_oQuery->insertItem(array(
  36. 'email' => $sEmail,
  37. 'subject' => $sSubject,
  38. 'body' => $sBody,
  39. 'headers' => $sHeaders,
  40. 'params' => $sParams
  41. )) > 0;
  42. }
  43. /**
  44. * Internal method which performs sending using predefined list of params.
  45. */
  46. protected function _send($sEmail, $sSubject, $sBody, $sHeaders = '', $sParams = '')
  47. {
  48. return mail($sEmail, $sSubject, $sBody, $sHeaders, $sParams);
  49. }
  50. }
  51. /** @} */