diff options
author | Christian Schneider | 2008-09-10 19:09:20 +0000 |
---|---|---|
committer | Christian Schneider | 2008-09-10 19:09:20 +0000 |
commit | 974c9e392c6571786a8d13f3948232b1305042d6 (patch) | |
tree | 15adef2e214b29c93e5e1b3706a9ba060bc3f85b /it_mail.class | |
parent | e523af554f89bef2b11f95433e7a561581d2614b (diff) | |
download | itools-974c9e392c6571786a8d13f3948232b1305042d6.tar.gz itools-974c9e392c6571786a8d13f3948232b1305042d6.tar.bz2 itools-974c9e392c6571786a8d13f3948232b1305042d6.zip |
Handle arrays for header values passed to it_mail
Diffstat (limited to 'it_mail.class')
-rw-r--r-- | it_mail.class | 44 |
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); } |