1: <?php
2: /**
3: * Abstract send email
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: /**
21: * Abstract transport for sending email
22: *
23: * @package Cake.Network.Email
24: */
25: abstract class AbstractTransport {
26:
27: /**
28: * Configurations
29: *
30: * @var array
31: */
32: protected $_config = array();
33:
34: /**
35: * Send mail
36: *
37: * @params CakeEmail $email
38: * @return array
39: */
40: abstract public function send(CakeEmail $email);
41:
42: /**
43: * Set the config
44: *
45: * @param array $config
46: * @return array Returns configs
47: */
48: public function config($config = null) {
49: if (is_array($config)) {
50: $this->_config = $config;
51: }
52: return $this->_config;
53: }
54:
55: /**
56: * Help to convert headers in string
57: *
58: * @param array $headers Headers in format key => value
59: * @param string $eol
60: * @return string
61: */
62: protected function _headersToString($headers, $eol = "\r\n") {
63: $out = '';
64: foreach ($headers as $key => $value) {
65: if ($value === false || $value === null || $value === '') {
66: continue;
67: }
68: $out .= $key . ': ' . $value . $eol;
69: }
70: if (!empty($out)) {
71: $out = substr($out, 0, -1 * strlen($eol));
72: }
73: return $out;
74: }
75:
76: }
77: