SendEvent.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. * Any recipients which failed after sending.
  32. * @var string[]
  33. */
  34. private $_failedRecipients = array();
  35. /**
  36. * The overall result as a bitmask from the class constants.
  37. * @var int
  38. */
  39. private $_result;
  40. /**
  41. * Create a new SendEvent for $source and $message.
  42. * @param Swift_Transport $source
  43. * @param Swift_Mime_Message $message
  44. */
  45. public function __construct(Swift_Transport $source,
  46. Swift_Mime_Message $message)
  47. {
  48. parent::__construct($source);
  49. $this->_message = $message;
  50. $this->_result = self::RESULT_PENDING;
  51. }
  52. /**
  53. * Get the Transport used to send the Message.
  54. * @return Swift_Transport
  55. */
  56. public function getTransport()
  57. {
  58. return $this->getSource();
  59. }
  60. /**
  61. * Get the Message being sent.
  62. * @return Swift_Mime_Message
  63. */
  64. public function getMessage()
  65. {
  66. return $this->_message;
  67. }
  68. /**
  69. * Set the array of addresses that failed in sending.
  70. * @param array $recipients
  71. */
  72. public function setFailedRecipients($recipients)
  73. {
  74. $this->_failedRecipients = $recipients;
  75. }
  76. /**
  77. * Get an recipient addresses which were not accepted for delivery.
  78. * @return string[]
  79. */
  80. public function getFailedRecipients()
  81. {
  82. return $this->_failedRecipients;
  83. }
  84. /**
  85. * Set the result of sending.
  86. * @return int
  87. */
  88. public function setResult($result)
  89. {
  90. $this->_result = $result;
  91. }
  92. /**
  93. * Get the result of this Event.
  94. * The return value is a bitmask from
  95. * {@link RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED}
  96. * @return int
  97. */
  98. public function getResult()
  99. {
  100. return $this->_result;
  101. }
  102. }