summaryrefslogtreecommitdiffstats
path: root/system/libraries/Email.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-01-28 22:51:06 +0100
committerFlorian Pritz <bluewind@server-speed.net>2011-01-28 22:58:52 +0100
commitce2b69675075444c9e40b72bcdd42ab7edbbe633 (patch)
tree2932f13b0db14fe53dc0622d888318db638a017f /system/libraries/Email.php
parentb6b8a6587c399bfd89e13e92ce04ee8486688e6e (diff)
update to CI 2.0
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system/libraries/Email.php')
-rwxr-xr-x[-rw-r--r--]system/libraries/Email.php397
1 files changed, 209 insertions, 188 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index d0f2ea9a5..e5af38f45 100644..100755
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -82,7 +82,7 @@ class CI_Email {
*
* The constructor can be passed an array of config values
*/
- function CI_Email($config = array())
+ public function __construct($config = array())
{
if (count($config) > 0)
{
@@ -106,9 +106,8 @@ class CI_Email {
* @param array
* @return void
*/
- function initialize($config = array())
+ public function initialize($config = array())
{
- $this->clear();
foreach ($config as $key => $val)
{
if (isset($this->$key))
@@ -125,11 +124,14 @@ class CI_Email {
}
}
}
+ $this->clear();
$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
$this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -138,7 +140,7 @@ class CI_Email {
* @access public
* @return void
*/
- function clear($clear_attachments = FALSE)
+ public function clear($clear_attachments = FALSE)
{
$this->_subject = "";
$this->_body = "";
@@ -146,6 +148,8 @@ class CI_Email {
$this->_header_str = "";
$this->_replyto_flag = FALSE;
$this->_recipients = array();
+ $this->_cc_array = array();
+ $this->_bcc_array = array();
$this->_headers = array();
$this->_debug_msg = array();
@@ -158,8 +162,10 @@ class CI_Email {
$this->_attach_type = array();
$this->_attach_disp = array();
}
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -170,7 +176,7 @@ class CI_Email {
* @param string
* @return void
*/
- function from($from, $name = '')
+ public function from($from, $name = '')
{
if (preg_match( '/\<(.*)\>/', $from, $match))
{
@@ -199,8 +205,10 @@ class CI_Email {
$this->_set_header('From', $name.' <'.$from.'>');
$this->_set_header('Return-Path', '<'.$from.'>');
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -211,7 +219,7 @@ class CI_Email {
* @param string
* @return void
*/
- function reply_to($replyto, $name = '')
+ public function reply_to($replyto, $name = '')
{
if (preg_match( '/\<(.*)\>/', $replyto, $match))
{
@@ -235,8 +243,10 @@ class CI_Email {
$this->_set_header('Reply-To', $name.' <'.$replyto.'>');
$this->_replyto_flag = TRUE;
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -246,7 +256,7 @@ class CI_Email {
* @param string
* @return void
*/
- function to($to)
+ public function to($to)
{
$to = $this->_str_to_array($to);
$to = $this->clean_email($to);
@@ -263,15 +273,18 @@ class CI_Email {
switch ($this->_get_protocol())
{
- case 'smtp' : $this->_recipients = $to;
- break;
- case 'sendmail' : $this->_recipients = implode(", ", $to);
+ case 'smtp' :
+ $this->_recipients = $to;
break;
- case 'mail' : $this->_recipients = implode(", ", $to);
+ case 'sendmail' :
+ case 'mail' :
+ $this->_recipients = implode(", ", $to);
break;
}
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -281,7 +294,7 @@ class CI_Email {
* @param string
* @return void
*/
- function cc($cc)
+ public function cc($cc)
{
$cc = $this->_str_to_array($cc);
$cc = $this->clean_email($cc);
@@ -297,8 +310,10 @@ class CI_Email {
{
$this->_cc_array = $cc;
}
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -309,7 +324,7 @@ class CI_Email {
* @param string
* @return void
*/
- function bcc($bcc, $limit = '')
+ public function bcc($bcc, $limit = '')
{
if ($limit != '' && is_numeric($limit))
{
@@ -333,8 +348,10 @@ class CI_Email {
{
$this->_set_header('Bcc', implode(", ", $bcc));
}
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -344,12 +361,13 @@ class CI_Email {
* @param string
* @return void
*/
- function subject($subject)
+ public function subject($subject)
{
$subject = $this->_prep_q_encoding($subject);
$this->_set_header('Subject', $subject);
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -359,11 +377,12 @@ class CI_Email {
* @param string
* @return void
*/
- function message($body)
+ public function message($body)
{
$this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -373,11 +392,12 @@ class CI_Email {
* @param string
* @return void
*/
- function attach($filename, $disposition = 'attachment')
+ public function attach($filename, $disposition = 'attachment')
{
$this->_attach_name[] = $filename;
$this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
$this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
+ return $this;
}
// --------------------------------------------------------------------
@@ -390,11 +410,11 @@ class CI_Email {
* @param string
* @return void
*/
- function _set_header($header, $value)
+ private function _set_header($header, $value)
{
$this->_headers[$header] = $value;
}
-
+
// --------------------------------------------------------------------
/**
@@ -404,7 +424,7 @@ class CI_Email {
* @param string
* @return array
*/
- function _str_to_array($email)
+ private function _str_to_array($email)
{
if ( ! is_array($email))
{
@@ -420,7 +440,7 @@ class CI_Email {
}
return $email;
}
-
+
// --------------------------------------------------------------------
/**
@@ -430,11 +450,12 @@ class CI_Email {
* @param string
* @return void
*/
- function set_alt_message($str = '')
+ public function set_alt_message($str = '')
{
$this->alt_message = ($str == '') ? '' : $str;
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -444,11 +465,12 @@ class CI_Email {
* @param string
* @return void
*/
- function set_mailtype($type = 'text')
+ public function set_mailtype($type = 'text')
{
$this->mailtype = ($type == 'html') ? 'html' : 'text';
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -458,11 +480,12 @@ class CI_Email {
* @param string
* @return void
*/
- function set_wordwrap($wordwrap = TRUE)
+ public function set_wordwrap($wordwrap = TRUE)
{
$this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -472,11 +495,12 @@ class CI_Email {
* @param string
* @return void
*/
- function set_protocol($protocol = 'mail')
+ public function set_protocol($protocol = 'mail')
{
$this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -486,7 +510,7 @@ class CI_Email {
* @param integer
* @return void
*/
- function set_priority($n = 3)
+ public function set_priority($n = 3)
{
if ( ! is_numeric($n))
{
@@ -501,8 +525,9 @@ class CI_Email {
}
$this->priority = $n;
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -512,7 +537,7 @@ class CI_Email {
* @param string
* @return void
*/
- function set_newline($newline = "\n")
+ public function set_newline($newline = "\n")
{
if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
{
@@ -521,8 +546,10 @@ class CI_Email {
}
$this->newline = $newline;
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -532,7 +559,7 @@ class CI_Email {
* @param string
* @return void
*/
- function set_crlf($crlf = "\n")
+ public function set_crlf($crlf = "\n")
{
if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
{
@@ -541,8 +568,10 @@ class CI_Email {
}
$this->crlf = $crlf;
+
+ return $this;
}
-
+
// --------------------------------------------------------------------
/**
@@ -551,12 +580,12 @@ class CI_Email {
* @access private
* @return void
*/
- function _set_boundaries()
+ private function _set_boundaries()
{
$this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
$this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
}
-
+
// --------------------------------------------------------------------
/**
@@ -565,7 +594,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_message_id()
+ private function _get_message_id()
{
$from = $this->_headers['Return-Path'];
$from = str_replace(">", "", $from);
@@ -573,7 +602,7 @@ class CI_Email {
return "<".uniqid('').strstr($from, '@').">";
}
-
+
// --------------------------------------------------------------------
/**
@@ -583,7 +612,7 @@ class CI_Email {
* @param bool
* @return string
*/
- function _get_protocol($return = TRUE)
+ private function _get_protocol($return = TRUE)
{
$this->protocol = strtolower($this->protocol);
$this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol;
@@ -593,7 +622,7 @@ class CI_Email {
return $this->protocol;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -603,7 +632,7 @@ class CI_Email {
* @param bool
* @return string
*/
- function _get_encoding($return = TRUE)
+ private function _get_encoding($return = TRUE)
{
$this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding;
@@ -629,7 +658,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_content_type()
+ private function _get_content_type()
{
if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
{
@@ -648,7 +677,7 @@ class CI_Email {
return 'plain';
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -657,7 +686,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _set_date()
+ private function _set_date()
{
$timezone = date("Z");
$operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
@@ -666,7 +695,7 @@ class CI_Email {
return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
}
-
+
// --------------------------------------------------------------------
/**
@@ -675,11 +704,11 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_mime_message()
+ private function _get_mime_message()
{
return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
}
-
+
// --------------------------------------------------------------------
/**
@@ -689,7 +718,7 @@ class CI_Email {
* @param string
* @return bool
*/
- function validate_email($email)
+ public function validate_email($email)
{
if ( ! is_array($email))
{
@@ -708,7 +737,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -718,11 +747,11 @@ class CI_Email {
* @param string
* @return bool
*/
- function valid_email($address)
+ public function valid_email($address)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -732,17 +761,17 @@ class CI_Email {
* @param string
* @return string
*/
- function clean_email($email)
+ public function clean_email($email)
{
if ( ! is_array($email))
{
if (preg_match('/\<(.*)\>/', $email, $match))
{
- return $match['1'];
+ return $match['1'];
}
- else
+ else
{
- return $email;
+ return $email;
}
}
@@ -752,23 +781,23 @@ class CI_Email {
{
if (preg_match( '/\<(.*)\>/', $addy, $match))
{
- $clean_email[] = $match['1'];
+ $clean_email[] = $match['1'];
}
- else
+ else
{
- $clean_email[] = $addy;
+ $clean_email[] = $addy;
}
}
return $clean_email;
}
-
+
// --------------------------------------------------------------------
/**
* Build alternative plain text message
*
- * This function provides the raw message for use
+ * This public function provides the raw message for use
* in plain-text headers of HTML-formatted emails.
* If the user hasn't specified his own alternative message
* it creates one by stripping the HTML
@@ -776,7 +805,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_alt_message()
+ private function _get_alt_message()
{
if ($this->alt_message != "")
{
@@ -802,7 +831,7 @@ class CI_Email {
for ($x = 1; $x <= $i; $x ++)
{
- $n .= "\n";
+ $n .= "\n";
}
$body = str_replace($n, "\n\n", $body);
@@ -810,7 +839,7 @@ class CI_Email {
return $this->word_wrap($body, '76');
}
-
+
// --------------------------------------------------------------------
/**
@@ -821,7 +850,7 @@ class CI_Email {
* @param integer
* @return string
*/
- function word_wrap($str, $charlim = '')
+ public function word_wrap($str, $charlim = '')
{
// Se the character limit
if ($charlim == '')
@@ -850,7 +879,7 @@ class CI_Email {
}
}
- // Use PHP's native function to do the initial wordwrap.
+ // Use PHP's native public function to do the initial wordwrap.
// We set the cut flag to FALSE so that any individual words that are
// too long get left alone. In the next step we'll deal with them.
$str = wordwrap($str, $charlim, "\n", FALSE);
@@ -906,7 +935,7 @@ class CI_Email {
return $output;
}
-
+
// --------------------------------------------------------------------
/**
@@ -916,7 +945,7 @@ class CI_Email {
* @param string
* @return string
*/
- function _build_headers()
+ private function _build_headers()
{
$this->_set_header('X-Sender', $this->clean_email($this->_headers['From']));
$this->_set_header('X-Mailer', $this->useragent);
@@ -924,7 +953,7 @@ class CI_Email {
$this->_set_header('Message-ID', $this->_get_message_id());
$this->_set_header('Mime-Version', '1.0');
}
-
+
// --------------------------------------------------------------------
/**
@@ -933,7 +962,7 @@ class CI_Email {
* @access private
* @return void
*/
- function _write_headers()
+ private function _write_headers()
{
if ($this->protocol == 'mail')
{
@@ -959,7 +988,7 @@ class CI_Email {
$this->_header_str = rtrim($this->_header_str);
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -968,7 +997,7 @@ class CI_Email {
* @access private
* @return void
*/
- function _build_message()
+ private function _build_message()
{
if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
{
@@ -979,6 +1008,7 @@ class CI_Email {
$this->_write_headers();
$hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
+ $body = '';
switch ($this->_get_content_type())
{
@@ -991,13 +1021,12 @@ class CI_Email {
{
$this->_header_str .= $hdr;
$this->_finalbody = $this->_body;
-
- return;
+ }
+ else
+ {
+ $this->_finalbody = $hdr . $this->newline . $this->newline . $this->_body;
}
- $hdr .= $this->newline . $this->newline . $this->_body;
-
- $this->_finalbody = $hdr;
return;
break;
@@ -1011,93 +1040,81 @@ class CI_Email {
else
{
$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_alt_boundary . $this->newline;
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+ $body .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $body .= "--" . $this->_alt_boundary . $this->newline;
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted-printable";
+ $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+ $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
}
- $this->_body = $this->_prep_quoted_printable($this->_body);
+ $this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
+
if ($this->_get_protocol() == 'mail')
{
$this->_header_str .= $hdr;
- $this->_finalbody = $this->_body . $this->newline . $this->newline;
-
- if ($this->send_multipart !== FALSE)
- {
- $this->_finalbody .= "--" . $this->_alt_boundary . "--";
- }
-
- return;
+ }
+ else
+ {
+ $this->_finalbody = $hdr . $this->_finalbody;
}
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
if ($this->send_multipart !== FALSE)
{
- $hdr .= "--" . $this->_alt_boundary . "--";
+ $this->_finalbody .= "--" . $this->_alt_boundary . "--";
}
- $this->_finalbody = $hdr;
return;
break;
case 'plain-attach' :
$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_atc_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
if ($this->_get_protocol() == 'mail')
{
$this->_header_str .= $hdr;
-
- $body = $this->_body . $this->newline . $this->newline;
}
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
+ $body .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $body .= "--" . $this->_atc_boundary . $this->newline;
+
+ $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+
+ $body .= $this->_body . $this->newline . $this->newline;
break;
case 'html-attach' :
$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
- $hdr .= $this->_get_mime_message() . $this->newline . $this->newline;
- $hdr .= "--" . $this->_atc_boundary . $this->newline;
-
- $hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
- $hdr .= "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $hdr .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
-
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted-printable";
-
- $this->_body = $this->_prep_quoted_printable($this->_body);
if ($this->_get_protocol() == 'mail')
{
$this->_header_str .= $hdr;
-
- $body = $this->_body . $this->newline . $this->newline;
- $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
}
- $hdr .= $this->newline . $this->newline;
- $hdr .= $this->_body . $this->newline . $this->newline;
- $hdr .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+ $body .= $this->_get_mime_message() . $this->newline . $this->newline;
+ $body .= "--" . $this->_atc_boundary . $this->newline;
+
+ $body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
+ $body .= "--" . $this->_alt_boundary . $this->newline;
+
+ $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
+ $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+
+ $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
+ $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
+
+ $body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
+ $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
break;
}
@@ -1137,18 +1154,21 @@ class CI_Email {
fclose($fp);
}
+ $body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
+
+
if ($this->_get_protocol() == 'mail')
{
- $this->_finalbody = $body . implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-
- return;
+ $this->_finalbody = $body;
+ }
+ else
+ {
+ $this->_finalbody = $hdr . $body;
}
-
- $this->_finalbody = $hdr.implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
return;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1162,7 +1182,7 @@ class CI_Email {
* @param integer
* @return string
*/
- function _prep_quoted_printable($str, $charlim = '')
+ private function _prep_quoted_printable($str, $charlim = '')
{
// Set the character limit
// Don't allow over 76, as that will make servers and MUAs barf
@@ -1243,7 +1263,7 @@ class CI_Email {
}
// --------------------------------------------------------------------
-
+
/**
* Prep Q Encoding
*
@@ -1255,7 +1275,7 @@ class CI_Email {
* @param bool // set to TRUE for processing From: headers
* @return str
*/
- function _prep_q_encoding($str, $from = FALSE)
+ private function _prep_q_encoding($str, $from = FALSE)
{
$str = str_replace(array("\r", "\n"), array('', ''), $str);
@@ -1315,14 +1335,14 @@ class CI_Email {
}
// --------------------------------------------------------------------
-
+
/**
* Send Email
*
* @access public
* @return bool
*/
- function send()
+ public function send()
{
if ($this->_replyto_flag == FALSE)
{
@@ -1356,7 +1376,7 @@ class CI_Email {
return TRUE;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1365,7 +1385,7 @@ class CI_Email {
* @access public
* @return bool
*/
- function batch_bcc_send()
+ public function batch_bcc_send()
{
$float = $this->bcc_batch_size -1;
@@ -1414,7 +1434,7 @@ class CI_Email {
$this->_spool_email();
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1423,11 +1443,11 @@ class CI_Email {
* @access private
* @return void
*/
- function _unwrap_specials()
+ private function _unwrap_specials()
{
$this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
}
-
+
// --------------------------------------------------------------------
/**
@@ -1436,7 +1456,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _remove_nl_callback($matches)
+ private function _remove_nl_callback($matches)
{
if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE)
{
@@ -1445,7 +1465,7 @@ class CI_Email {
return $matches[1];
}
-
+
// --------------------------------------------------------------------
/**
@@ -1454,7 +1474,7 @@ class CI_Email {
* @access private
* @return bool
*/
- function _spool_email()
+ private function _spool_email()
{
$this->_unwrap_specials();
@@ -1490,7 +1510,7 @@ class CI_Email {
$this->_set_error_message('email_sent', $this->_get_protocol());
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1499,7 +1519,7 @@ class CI_Email {
* @access private
* @return bool
*/
- function _send_with_mail()
+ private function _send_with_mail()
{
if ($this->_safe_mode == TRUE)
{
@@ -1516,6 +1536,7 @@ class CI_Email {
{
// most documentation of sendmail using the "-f" flag lacks a space after it, however
// we've encountered servers that seem to require it to be in place.
+
if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
{
return FALSE;
@@ -1526,7 +1547,7 @@ class CI_Email {
}
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1535,7 +1556,7 @@ class CI_Email {
* @access private
* @return bool
*/
- function _send_with_sendmail()
+ private function _send_with_sendmail()
{
$fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w');
@@ -1544,17 +1565,17 @@ class CI_Email {
// server probably has popen disabled, so nothing we can do to get a verbose error.
return FALSE;
}
-
+
fputs($fp, $this->_header_str);
fputs($fp, $this->_finalbody);
- $status = pclose($fp);
-
+ $status = pclose($fp);
+
if (version_compare(PHP_VERSION, '4.2.3') == -1)
{
$status = $status >> 8 & 0xFF;
- }
-
+ }
+
if ($status != 0)
{
$this->_set_error_message('email_exit_status', $status);
@@ -1564,7 +1585,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1573,7 +1594,7 @@ class CI_Email {
* @access private
* @return bool
*/
- function _send_with_smtp()
+ private function _send_with_smtp()
{
if ($this->smtp_host == '')
{
@@ -1633,7 +1654,7 @@ class CI_Email {
$this->_send_command('quit');
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1643,7 +1664,7 @@ class CI_Email {
* @param string
* @return string
*/
- function _smtp_connect()
+ private function _smtp_connect()
{
$this->_smtp_connect = fsockopen($this->smtp_host,
$this->smtp_port,
@@ -1660,7 +1681,7 @@ class CI_Email {
$this->_set_error_message($this->_get_smtp_data());
return $this->_send_command('hello');
}
-
+
// --------------------------------------------------------------------
/**
@@ -1671,7 +1692,7 @@ class CI_Email {
* @param string
* @return string
*/
- function _send_command($cmd, $data = '')
+ private function _send_command($cmd, $data = '')
{
switch ($cmd)
{
@@ -1727,7 +1748,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1736,7 +1757,7 @@ class CI_Email {
* @access private
* @return bool
*/
- function _smtp_authenticate()
+ private function _smtp_authenticate()
{
if ( ! $this->_smtp_auth)
{
@@ -1781,7 +1802,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1790,7 +1811,7 @@ class CI_Email {
* @access private
* @return bool
*/
- function _send_data($data)
+ private function _send_data($data)
{
if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
{
@@ -1802,7 +1823,7 @@ class CI_Email {
return TRUE;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1811,7 +1832,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_smtp_data()
+ private function _get_smtp_data()
{
$data = "";
@@ -1827,7 +1848,7 @@ class CI_Email {
return $data;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1836,11 +1857,11 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_hostname()
+ private function _get_hostname()
{
return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
}
-
+
// --------------------------------------------------------------------
/**
@@ -1849,7 +1870,7 @@ class CI_Email {
* @access private
* @return string
*/
- function _get_ip()
+ private function _get_ip()
{
if ($this->_IP !== FALSE)
{
@@ -1860,12 +1881,12 @@ class CI_Email {
$rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
$fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
- if ($cip && $rip) $this->_IP = $cip;
+ if ($cip && $rip) $this->_IP = $cip;
elseif ($rip) $this->_IP = $rip;
elseif ($cip) $this->_IP = $cip;
elseif ($fip) $this->_IP = $fip;
- if (strstr($this->_IP, ','))
+ if (strpos($this->_IP, ',') !== FALSE)
{
$x = explode(',', $this->_IP);
$this->_IP = end($x);
@@ -1882,7 +1903,7 @@ class CI_Email {
return $this->_IP;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1891,7 +1912,7 @@ class CI_Email {
* @access public
* @return string
*/
- function print_debugger()
+ public function print_debugger()
{
$msg = '';
@@ -1906,7 +1927,7 @@ class CI_Email {
$msg .= "<pre>".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>';
return $msg;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1916,7 +1937,7 @@ class CI_Email {
* @param string
* @return string
*/
- function _set_error_message($msg, $val = '')
+ private function _set_error_message($msg, $val = '')
{
$CI =& get_instance();
$CI->lang->load('email');
@@ -1930,7 +1951,7 @@ class CI_Email {
$this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1940,7 +1961,7 @@ class CI_Email {
* @param string
* @return string
*/
- function _mime_types($ext = "")
+ private function _mime_types($ext = "")
{
$mimes = array( 'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',