SendEvent.php 2.7KB

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