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