summaryrefslogtreecommitdiff
path: root/it_mail.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_mail.class')
-rw-r--r--it_mail.class44
1 files changed, 12 insertions, 32 deletions
diff --git a/it_mail.class b/it_mail.class
index 7a09085..9057ef3 100644
--- a/it_mail.class
+++ b/it_mail.class
@@ -62,13 +62,10 @@ class it_mail
* Note: Headers To, Cc, Bcc can be arrays
* @param $headers Array of headers for this email, e.g. From, To and Subject
*/
-function it_mail($headers = "")
+function it_mail($headers = array())
{
- if (is_array($headers))
- {
- foreach ($headers as $header => $value)
- $this->add_header($header, $value);
- }
+ foreach ((array)$headers as $header => $value)
+ $this->add_header($header, $value);
}
@@ -80,42 +77,25 @@ function it_mail($headers = "")
*/
function add_header($header, $value)
{
- $value = $this->header_escape($value);
-
switch ($header)
{
case 'To':
- if (is_array($value))
- {
- foreach ($value as $val)
- $this->to[] = $val;
- }
- else
- $this->to[] = $value;
+ foreach ((array)$value as $val)
+ $this->to[] = $this->header_escape($val);
break;
case 'Subject':
- $this->subject .= $value;
+ $this->subject .= $value; # Escape on sending
break;
case 'Cc':
- if (is_array($value))
- {
- foreach ($value as $val)
- $this->cc[] = $val;
- }
- else
- $this->cc[] = $value;
+ foreach ((array)$value as $val)
+ $this->cc[] = $this->header_escape($val);
break;
case 'Bcc':
- if (is_array($value))
- {
- foreach ($value as $val)
- $this->bcc[] = $val;
- }
- else
- $this->bcc[] = $value;
+ foreach ((array)$value as $val)
+ $this->bcc[] = $this->header_escape($val);
break;
case 'charset':
@@ -127,7 +107,7 @@ function add_header($header, $value)
/* FALLTHROUGH */
default:
$this->header_names[] = $header;
- $this->header_values[] = $value;
+ $this->header_values[] = $this->header_escape($value);
break;
}
}
@@ -305,7 +285,7 @@ function send()
$text .= "--$boundary1--\n";
}
- return mail($to, $this->subject, $text, join("\n", $headers), $this->flags);
+ return mail($to, $this->header_escape($this->subject), $text, join("\n", $headers), $this->flags);
}