SendEvent.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Generated when a message is being sent.
  11. *
  12. * @author Chris Corbyn
  13. */
  14. class Swift_Events_SendEvent extends Swift_Events_EventObject
  15. {
  16. /** Sending has yet to occur */
  17. const RESULT_PENDING = 0x0001;
  18. /** Sending was successful */
  19. const RESULT_SUCCESS = 0x0010;
  20. /** Sending worked, but there were some failures */
  21. const RESULT_TENTATIVE = 0x0100;
  22. /** Sending failed */
  23. const RESULT_FAILED = 0x1000;
  24. /**
  25. * The Message being sent.
  26. *
  27. * @var Swift_Mime_Message
  28. */
  29. private $_message;
  30. /**
  31. * Any recipients which failed after sending.
  32. *
  33. * @var string[]
  34. */
  35. private $_failedRecipients = array();
  36. /**
  37. * The overall result as a bitmask from the class constants.
  38. *
  39. * @var int
  40. */
  41. private $_result;
  42. /**
  43. * Create a new SendEvent for $source and $message.
  44. *
  45. * @param Swift_Transport $source
  46. * @param Swift_Mime_Message $message
  47. */
  48. public function __construct(Swift_Transport $source, Swift_Mime_Message $message)
  49. {
  50. parent::__construct($source);
  51. $this->_message = $message;
  52. $this->_result = self::RESULT_PENDING;
  53. }
  54. /**
  55. * Get the Transport used to send the Message.
  56. *
  57. * @return Swift_Transport
  58. */
  59. public function getTransport()
  60. {
  61. return $this->getSource();
  62. }
  63. /**
  64. * Get the Message being sent.
  65. *
  66. * @return Swift_Mime_Message
  67. */
  68. public function getMessage()
  69. {
  70. return $this->_message;
  71. }
  72. /**
  73. * Set the array of addresses that failed in sending.
  74. *
  75. * @param array $recipients
  76. */
  77. public function setFailedRecipients($recipients)
  78. {
  79. $this->_failedRecipients = $recipients;
  80. }
  81. /**
  82. * Get an recipient addresses which were not accepted for delivery.
  83. *
  84. * @return string[]
  85. */
  86. public function getFailedRecipients()
  87. {
  88. return $this->_failedRecipients;
  89. }
  90. /**
  91. * Set the result of sending.
  92. *
  93. * @param int $result
  94. */
  95. public function setResult($result)
  96. {
  97. $this->_result = $result;
  98. }
  99. /**
  100. * Get the result of this Event.
  101. *
  102. * The return value is a bitmask from
  103. * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED}
  104. *
  105. * @return int
  106. */
  107. public function getResult()
  108. {
  109. return $this->_result;
  110. }
  111. }