"Fixes #3820, Email Component only sends message if using template and layout.

Fixes #4019, email component: attaching file is broke, fixes undefined variable, allows full paths to attachment.
Fixes #4171, Email Component: Lost a head line 'period' via SMTP method.
"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6522 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-03-08 20:26:16 +00:00
parent 58e6da6a5b
commit 63144591c6
2 changed files with 14 additions and 8 deletions

View file

@ -506,6 +506,7 @@ class EmailComponent extends Object{
* @access private
*/
function __attachFiles() {
$files = array();
foreach ($this->attachments as $attachment) {
$file = $this->__findFiles($attachment);
if (!empty($file)) {
@ -538,6 +539,9 @@ class EmailComponent extends Object{
* @access private
*/
function __findFiles($attachment) {
if (file_exists($attachment)) {
return $attachment;
}
foreach ($this->filePaths as $path) {
if (file_exists($path . DS . $attachment)) {
$file = $path . DS . $attachment;
@ -556,14 +560,17 @@ class EmailComponent extends Object{
function __wrap($message) {
$message = $this->__strip($message, true);
$message = str_replace(array("\r\n","\r"), "\n", $message);
$words = explode("\n", $message);
$formated = null;
$lines = explode("\n", $message);
$formatted = null;
foreach ($words as $word) {
$formated .= wordwrap($word, $this->_lineLength, $this->_newLine, true);
$formated .= $this->_newLine;
foreach ($lines as $line) {
if(substr($line, 0, 1) == '.') {
$line = '.' . $line;
}
$formatted .= wordwrap($line, $this->_lineLength, $this->_newLine, true);
$formatted .= $this->_newLine;
}
return $formated;
return $formatted;
}
/**
* Encode the specified string using the current charset
@ -687,7 +694,7 @@ class EmailComponent extends Object{
return false;
}
if (!$this->__sendData($this->__header . "\r\n" . $this->__message . "\r\n\r\n\r\n.\r\n")) {
if (!$this->__sendData($this->__header . "\r\n\r\n" . $this->__message . "\r\n\r\n\r\n.\r\n")) {
return false;
}
$this->__sendData("QUIT\r\n", false);

View file

@ -24,7 +24,6 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<?php echo $content_for_layout;?>
This email was sent using the CakePHP Framework, http://cakephp.org.