2011-03-01 16:47:05 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Abstract send email
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2012-03-13 02:46:46 +00:00
|
|
|
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2011-03-01 16:47:05 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2012-03-13 02:46:46 +00:00
|
|
|
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2011-03-01 16:47:05 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Network.Email
|
2011-03-01 16:47:05 +00:00
|
|
|
* @since CakePHP(tm) v 2.0.0
|
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-12-08 15:35:02 +00:00
|
|
|
* Abstract transport for sending email
|
2011-03-01 16:47:05 +00:00
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Network.Email
|
2011-03-01 16:47:05 +00:00
|
|
|
*/
|
|
|
|
abstract class AbstractTransport {
|
|
|
|
|
2011-04-10 03:08:05 +00:00
|
|
|
/**
|
|
|
|
* Configurations
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_config = array();
|
|
|
|
|
2011-03-01 16:47:05 +00:00
|
|
|
/**
|
|
|
|
* Send mail
|
|
|
|
*
|
2011-08-31 22:09:41 +00:00
|
|
|
* @params CakeEmail $email
|
2011-08-26 00:31:18 +00:00
|
|
|
* @return array
|
2011-03-01 16:47:05 +00:00
|
|
|
*/
|
|
|
|
abstract public function send(CakeEmail $email);
|
|
|
|
|
2011-04-13 04:04:37 +00:00
|
|
|
/**
|
|
|
|
* Set the config
|
|
|
|
*
|
|
|
|
* @param array $config
|
2011-08-29 01:11:30 +00:00
|
|
|
* @return array Returns configs
|
2011-04-13 04:04:37 +00:00
|
|
|
*/
|
2011-08-29 01:11:30 +00:00
|
|
|
public function config($config = null) {
|
|
|
|
if (is_array($config)) {
|
2011-04-13 04:04:37 +00:00
|
|
|
$this->_config = $config;
|
|
|
|
}
|
2011-08-29 01:11:30 +00:00
|
|
|
return $this->_config;
|
2011-04-13 04:04:37 +00:00
|
|
|
}
|
|
|
|
|
2011-03-01 16:47:05 +00:00
|
|
|
/**
|
|
|
|
* Help to convert headers in string
|
|
|
|
*
|
|
|
|
* @param array $headers Headers in format key => value
|
|
|
|
* @param string $eol
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function _headersToString($headers, $eol = "\r\n") {
|
|
|
|
$out = '';
|
|
|
|
foreach ($headers as $key => $value) {
|
2011-04-04 04:26:42 +00:00
|
|
|
if ($value === false || $value === null || $value === '') {
|
|
|
|
continue;
|
|
|
|
}
|
2011-03-01 16:47:05 +00:00
|
|
|
$out .= $key . ': ' . $value . $eol;
|
|
|
|
}
|
|
|
|
if (!empty($out)) {
|
|
|
|
$out = substr($out, 0, -1 * strlen($eol));
|
|
|
|
}
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|