SendEvent.php 2.6KB

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