From e9515d1ee18074928ae1e013dd0ff8666ecbd475 Mon Sep 17 00:00:00 2001 From: marcus Date: Mon, 29 Sep 2008 10:23:35 +0000 Subject: Closes #369: For entities which are not users the ->email field is used, failing that it tries to work out an address from ->url and lastly from $CONFIG->site_guid. Closes #382: Fix applied as suggested. git-svn-id: https://code.elgg.org/elgg/trunk@2143 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/notification.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/notification.php b/engine/lib/notification.php index 4bc0a0476..192e011fc 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -220,24 +220,24 @@ if ($to->email=="") throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid)); - + + // To $to = $to->email; - /*if (!$hide_sender) + + // From + $site = get_entity($CONFIG->site_guid); + if ((isset($from->email)) && (!($from instanceof ElggUser))) // If there's an email address, use it - but only if its not from a user. + $from = $from->from; + 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. { - if ($from->email) - $from = $from->email; // Handle users - else if ($from->url) - { - $breakdown = parse_url($from->url); - $from = 'noreply@' . $breakdown['host']; // Handle anything with a url - } - else { - $from = 'noreply@' . get_site_domain($CONFIG->site_guid); // Handle a fallback - } + $breakdown = parse_url($from->url); + $from = 'noreply@' . $breakdown['host']; // Handle anything with a url } - else*/ - $from = 'noreply@' . get_site_domain($CONFIG->site_guid); // Handle a fallback - + 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'); } @@ -246,7 +246,7 @@ if (is_callable('mb_encode_mimeheader')) { $sitename = mb_encode_mimeheader($site->name,"UTF-8", "B"); } - $headers = "From: $sitename <$from>\r\n" + $headers = "From: \"$sitename\" <$from>\r\n" . "Content-Type: text/plain; charset=UTF-8; format=flowed\r\n" . "MIME-Version: 1.0\r\n" . "Content-Transfer-Encoding: 8bit\r\n"; -- cgit v1.2.3