pictcode / lib / Cake / Network / Email / AbstractTransport.php @ 635eef61
履歴 | 表示 | アノテート | ダウンロード (1.724 KB)
| 1 |
<?php
|
|---|---|
| 2 |
/**
|
| 3 |
* Abstract send email
|
| 4 |
*
|
| 5 |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
| 6 |
* Copyright (c) Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org)
|
| 13 |
* @link http://cakephp.org CakePHP(tm) Project
|
| 14 |
* @package Cake.Network.Email
|
| 15 |
* @since CakePHP(tm) v 2.0.0
|
| 16 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
| 17 |
*/
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Abstract transport for sending email
|
| 21 |
*
|
| 22 |
* @package Cake.Network.Email
|
| 23 |
*/
|
| 24 |
abstract class AbstractTransport { |
| 25 |
|
| 26 |
/**
|
| 27 |
* Configurations
|
| 28 |
*
|
| 29 |
* @var array
|
| 30 |
*/
|
| 31 |
protected $_config = array(); |
| 32 |
|
| 33 |
/**
|
| 34 |
* Send mail
|
| 35 |
*
|
| 36 |
* @param CakeEmail $email CakeEmail instance.
|
| 37 |
* @return array
|
| 38 |
*/
|
| 39 |
abstract public function send(CakeEmail $email); |
| 40 |
|
| 41 |
/**
|
| 42 |
* Set the config
|
| 43 |
*
|
| 44 |
* @param array $config Configuration options.
|
| 45 |
* @return array Returns configs
|
| 46 |
*/
|
| 47 |
public function config($config = null) { |
| 48 |
if (is_array($config)) { |
| 49 |
$this->_config = $config + $this->_config; |
| 50 |
} |
| 51 |
return $this->_config; |
| 52 |
} |
| 53 |
|
| 54 |
/**
|
| 55 |
* Help to convert headers in string
|
| 56 |
*
|
| 57 |
* @param array $headers Headers in format key => value
|
| 58 |
* @param string $eol End of line string.
|
| 59 |
* @return string
|
| 60 |
*/
|
| 61 |
protected function _headersToString($headers, $eol = "\r\n") { |
| 62 |
$out = ''; |
| 63 |
foreach ($headers as $key => $value) { |
| 64 |
if ($value === false || $value === null || $value === '') { |
| 65 |
continue;
|
| 66 |
} |
| 67 |
$out .= $key . ': ' . $value . $eol; |
| 68 |
} |
| 69 |
if (!empty($out)) { |
| 70 |
$out = substr($out, 0, -1 * strlen($eol)); |
| 71 |
} |
| 72 |
return $out; |
| 73 |
} |
| 74 |
|
| 75 |
} |