DebugTransport.php 1.3 KB

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