1: <?php
2: /**
3: * Emulates the email sending process for testing purposes
4: *
5: * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
6: * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
7: *
8: * Licensed under The MIT License
9: * For full copyright and license information, please see the LICENSE.txt
10: * Redistributions of files must retain the above copyright notice.
11: *
12: * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
13: * @link https://cakephp.org CakePHP(tm) Project
14: * @package Cake.Network.Email
15: * @since CakePHP(tm) v 2.0.0
16: * @license https://opensource.org/licenses/mit-license.php MIT License
17: */
18: App::uses('AbstractTransport', 'Network/Email');
19:
20: /**
21: * Debug Transport class, useful for emulate the email sending process and inspect the resulted
22: * email message before actually send it during development
23: *
24: * @package Cake.Network.Email
25: */
26: class DebugTransport extends AbstractTransport {
27:
28: /**
29: * Send mail
30: *
31: * @param CakeEmail $email CakeEmail
32: * @return array
33: */
34: public function send(CakeEmail $email) {
35: $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
36: $headers = $this->_headersToString($headers);
37: $message = implode("\r\n", (array)$email->message());
38: return array('headers' => $headers, 'message' => $message);
39: }
40:
41: }
42: