PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Cake/Network/Email/AbstractTransport.php

https://bitbucket.org/udeshika/fake_twitter
PHP | 76 lines | 24 code | 6 blank | 46 comment | 5 complexity | b9c75b6e408f0bc835aa77aa44c60bb8 MD5 | raw file
  1. <?php
  2. /**
  3. * Abstract send email
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, 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-2011, 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. * Abstract transport for sending email
  21. *
  22. * @package Cake.Network.Email
  23. */
  24. abstract class AbstractTransport {
  25. /**
  26. * Configurations
  27. *
  28. * @var array
  29. */
  30. protected $_config = array();
  31. /**
  32. * Send mail
  33. *
  34. * @params CakeEmail $email
  35. * @return array
  36. */
  37. abstract public function send(CakeEmail $email);
  38. /**
  39. * Set the config
  40. *
  41. * @param array $config
  42. * @return array Returns configs
  43. */
  44. public function config($config = null) {
  45. if (is_array($config)) {
  46. $this->_config = $config;
  47. }
  48. return $this->_config;
  49. }
  50. /**
  51. * Help to convert headers in string
  52. *
  53. * @param array $headers Headers in format key => value
  54. * @param string $eol
  55. * @return string
  56. */
  57. protected function _headersToString($headers, $eol = "\r\n") {
  58. $out = '';
  59. foreach ($headers as $key => $value) {
  60. if ($value === false || $value === null || $value === '') {
  61. continue;
  62. }
  63. $out .= $key . ': ' . $value . $eol;
  64. }
  65. if (!empty($out)) {
  66. $out = substr($out, 0, -1 * strlen($eol));
  67. }
  68. return $out;
  69. }
  70. }