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