Index: trunk/core/kernel/utility/email.php =================================================================== diff -u -r3527 -r3540 --- trunk/core/kernel/utility/email.php (.../email.php) (revision 3527) +++ trunk/core/kernel/utility/email.php (.../email.php) (revision 3540) @@ -48,9 +48,17 @@ $this->Compiled = false; } + function fixLineBreaks($data) + { + $data = str_replace("\n\n","\r\n\r\n",$data); + $data = str_replace("\r\n","\n",$data); + $data = str_replace("\n","\r\n",$data); + return $data; + } + function setHeaders($headers){ - $headers=str_replace("\r", "", $headers); - $headers_lines = explode("\n", $headers); + $headers=$this->fixLineBreaks($headers); + $headers_lines = explode("\r\n", $headers); foreach ($headers_lines as $line_num => $line){ list($header_field, $header_value) = explode(':', $line, 2); $header_value = trim($header_value); @@ -184,11 +192,11 @@ //$this->Body .= 'Content-Type: multipart/alternative;'.$this->LF()." ".'boundary="----='.$this->TextBoundary.'"'.$this->LF(); //$this->Body .= $this->LF(); $this->Body .= '------='.$this->EmailBoundary.$this->LF(); - $this->Body .= 'Content-Type: text/plain;'.$this->LF()." ".'charset="'.$this->Charset.'"'.$this->LF(); + $this->Body .= 'Content-Type: text/plain;'." ".'charset="'.$this->Charset.'"'.$this->LF(); $this->Body .= $this->LF(); $this->Body .= $not_html.$this->LF().$this->LF(); $this->Body .= '------='.$this->EmailBoundary.$this->LF(); - $this->Body .= 'Content-Type: text/html;'.$this->LF()." ".'charset="'.$this->Charset.'"'.$this->LF(); + $this->Body .= 'Content-Type: text/html;'." ".'charset="'.$this->Charset.'"'.$this->LF(); $this->Body .= 'Content-Transfer-Encoding: '.$this->TransferEncoding.$this->LF(); $this->Body .= 'Content-Description: HTML part'.$this->LF(); $this->Body .= 'Content-Disposition: inline'.$this->LF(); @@ -227,8 +235,6 @@ } - - function setCharset($charset){ $this->Charset = $charset; $this->Compiled = false; @@ -238,8 +244,6 @@ $this->LineFeed=$linefeed; } - - function attachFile($filepath, $mime="application/octet-stream"){ if(is_file($filepath)){ @@ -262,8 +266,7 @@ function getContentType(){ $content_type=""; if ($this->IsMultipart){ - $content_type .= $this->LF('multipart/alternative;'); - $content_type .= $this->LF(" ".'boundary="----='.$this->EmailBoundary.'"'); + $content_type .= $this->LF('multipart/alternative; boundary="----='.$this->EmailBoundary.'"'); }else{ $content_type .= $this->LF('text/plain;'); $content_type .= $this->LF(" ".'charset='.$this->Charset); @@ -314,6 +317,9 @@ } + if ($this->IsMultipart) { + $this->Headers .= 'MIME-Version: 1.0'.$this->LF(); + } $this->Headers .= "Content-Type: ".$this->getContentType(); //$this->Headers .= "Content-Transfer-Encoding: ".$this->TransferEncoding.$this->LF(); @@ -359,6 +365,10 @@ $this->Body .= '------='.$this->EmailBoundary.'--'.$this->LF(); } + $this->Body = $this->fixLineBreaks($this->Body); + $this->Headers = $this->fixLineBreaks($this->Headers); + + $this->Compiled = true; } @@ -406,16 +416,13 @@ else { $send_params['recipients'] = array($this->To); // The recipients (can be multiple) } - $send_params['headers'] = array( - 'From: '.$this->HeadersArray['From'], // Headers - 'To: '.$this->HeadersArray['To'], - 'Subject: '.$this->HeadersArray['Subject'], - 'Content-type: '.$this->getContentType(), - $this->getBody(), - ); + + $send_params['headers'] = explode("\r\n", $this->getHeaders()); + + array_unshift($send_params['headers'], 'To: '.$this->HeadersArray['To']); $send_params['from'] = $this->From; // This is used as in the MAIL FROM: cmd // It should end up as the Return-Path: header - $send_params['body']="\n"; + $send_params['body']=$this->getBody(); if($smtp_object->connect($params) && $smtp_object->send($send_params)){