SendEvent.php 2.5KB

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