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: * @since 2.0.0
15: * @license https://opensource.org/licenses/mit-license.php MIT License
16: */
17: namespace Cake\Mailer\Transport;
18:
19: use Cake\Mailer\AbstractTransport;
20: use Cake\Mailer\Email;
21:
22: /**
23: * Debug Transport class, useful for emulating the email sending process and inspecting
24: * the resultant email message before actually sending it during development
25: */
26: class DebugTransport extends AbstractTransport
27: {
28:
29: /**
30: * Send mail
31: *
32: * @param \Cake\Mailer\Email $email Cake Email
33: * @return array
34: */
35: public function send(Email $email)
36: {
37: $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']);
38: $headers = $this->_headersToString($headers);
39: $message = implode("\r\n", (array)$email->message());
40:
41: return ['headers' => $headers, 'message' => $message];
42: }
43: }
44: