1: <?php
2: /**
3: * @package Kolab_Filter
4: */
5:
6: /**
7: * Delivers a mail to STDOUT for debugging.
8: *
9: * Copyright 2008 Klarälvdalens Datakonsult AB
10: *
11: * See the enclosed file COPYING for license information (LGPL). If you
12: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
13: *
14: * @author Gunnar Wrobel <wrobel@pardus.de>
15: * @package Kolab_Filter
16: */
17: class Horde_Kolab_Filter_Transport_stdout extends Horde_Kolab_Filter_Transport
18: {
19: /**
20: * Create the transport handler.
21: *
22: * @return StdOutWrapper Wraps STDOUT as transport
23: */
24: function _createTransport()
25: {
26: $transport = new StdOutWrapper();
27: return $transport;
28: }
29: }
30:
31: /**
32: * Defines a STDOUT wrapper that provides functionality comparable to
33: * the Net/*MTP.php classes.
34: *
35: * Copyright 2008 Klarälvdalens Datakonsult AB
36: *
37: * See the enclosed file COPYING for license information (LGPL). If you
38: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
39: *
40: * @author Gunnar Wrobel <wrobel@pardus.de>
41: * @package Kolab_Filter
42: */
43: class StdOutWrapper
44: {
45: /**
46: * Pretends to connect to STDOUT.
47: *
48: * @return boolean Always true.
49: */
50: function connect()
51: {
52: return true;
53: }
54:
55: /**
56: * Pretends to disconnect from STDOUT.
57: *
58: * @return boolean Always true.
59: */
60: function disconnect()
61: {
62: return true;
63: }
64:
65: /**
66: * Set the sender.
67: *
68: * @return mixed Result from writing the sender to STDOUT.
69: */
70: function mailFrom($sender)
71: {
72: return fwrite(STDOUT, sprintf("Mail from sender: %s\n", $sender));
73: }
74:
75: /**
76: * Set the recipient.
77: *
78: * @return mixed Result from writing the recipient to STDOUT.
79: */
80: function rcptTo($recipient)
81: {
82: return fwrite(STDOUT, sprintf("Mail to recipient: %s\n", $recipient));
83: }
84:
85: /**
86: * Pretends to send commands to STDOUT.
87: *
88: * @param string $cmd The command.
89: *
90: * @return boolean Always true.
91: */
92: function _put($cmd)
93: {
94: return true;
95: }
96:
97: /**
98: * Pretends to handle STDOUT responses.
99: *
100: * @param string $code The response to parse.
101: *
102: * @return boolean Always true.
103: */
104: function _parseResponse($code)
105: {
106: return true;
107: }
108:
109: /**
110: * Write data to STDOUT.
111: *
112: * @param string $data The data to write.
113: *
114: * @return mixed Result from writing data to STDOUT.
115: */
116: function _send($data)
117: {
118: return fwrite(STDOUT, $data);
119: }
120: }
121: