diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-14 20:01:59 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-14 20:01:59 +0000 |
commit | b6aaba915151dd07800761a01b67ffffaee1302b (patch) | |
tree | 53c30035411460270278943f2427405233b34fac /engine/lib/notification.php | |
parent | ffbd7cd4179a0186dc674c2d24f578660cc75df0 (diff) | |
download | elgg-b6aaba915151dd07800761a01b67ffffaee1302b.tar.gz elgg-b6aaba915151dd07800761a01b67ffffaee1302b.tar.bz2 |
merge -r5898:5928 (not excluding riverdashboard, notifications, and messageboard) from 1.7 to trunk.
git-svn-id: http://code.elgg.org/elgg/trunk@6058 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/notification.php')
-rw-r--r-- | engine/lib/notification.php | 56 |
1 files changed, 5 insertions, 51 deletions
diff --git a/engine/lib/notification.php b/engine/lib/notification.php index 58e2a10f6..726f76993 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -243,9 +243,6 @@ function email_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid)); } - // Sanitise subject - $subject = preg_replace("/(\r\n|\r|\n)/", " ", $subject); // Strip line endings - // To $to = $to->email; @@ -257,55 +254,12 @@ function email_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message } else if (($site) && (isset($site->email))) { // Has the current site got a from email address? $from = $site->email; - } else if (isset($from->url)) { - // If we have a url then try and use that. - $breakdown = parse_url($from->url); - $from = 'noreply@' . $breakdown['host']; // Handle anything with a url } else { // If all else fails, use the domain of the site. $from = 'noreply@' . get_site_domain($CONFIG->site_guid); } - if (is_callable('mb_internal_encoding')) { - mb_internal_encoding('UTF-8'); - } - $site = get_entity($CONFIG->site_guid); - $sitename = $site->name; - if (is_callable('mb_encode_mimeheader')) { - $sitename = mb_encode_mimeheader($site->name,"UTF-8", "B"); - } - - $header_eol = "\r\n"; - if ( - (isset($CONFIG->broken_mta)) && - ($CONFIG->broken_mta) - ) { - // Allow non-RFC 2822 mail headers to support some broken MTAs - $header_eol = "\n"; - } - - $from_email = "\"$sitename\" <$from>"; - if (strtolower(substr(PHP_OS, 0 , 3)) == 'win') { - // Windows is somewhat broken, so we use a different format from header - $from_email = "$from"; - } - - $headers = "From: $from_email{$header_eol}" - . "Content-Type: text/plain; charset=UTF-8; format=flowed{$header_eol}" - . "MIME-Version: 1.0{$header_eol}" - . "Content-Transfer-Encoding: 8bit{$header_eol}"; - - if (is_callable('mb_encode_mimeheader')) { - $subject = mb_encode_mimeheader($subject,"UTF-8", "B"); - } - - // Format message - $message = html_entity_decode($message, ENT_COMPAT, 'UTF-8'); // Decode any html entities - $message = strip_tags($message); // Strip tags from message - $message = preg_replace("/(\r\n|\r)/", "\n", $message); // Convert to unix line endings in body - $message = preg_replace("/^From/", ">From", $message); // Change lines starting with From to >From - - return mail($to, $subject, wordwrap($message), $headers); + return elgg_send_email($from, $to, $subject, $message); } /** @@ -372,10 +326,10 @@ function elgg_send_email($from, $to, $subject, $body, array $params = NULL) { } // Format message - $message = html_entity_decode($body, ENT_COMPAT, 'UTF-8'); // Decode any html entities - $message = strip_tags($body); // Strip tags from message - $message = preg_replace("/(\r\n|\r)/", "\n", $body); // Convert to unix line endings in body - $message = preg_replace("/^From/", ">From", $body); // Change lines starting with From to >From + $body = html_entity_decode($body, ENT_COMPAT, 'UTF-8'); // Decode any html entities + $body = strip_tags($body); // Strip tags from message + $body = preg_replace("/(\r\n|\r)/", "\n", $body); // Convert to unix line endings in body + $body = preg_replace("/^From/", ">From", $body); // Change lines starting with From to >From return mail($to, $subject, wordwrap($body), $headers); } |