aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-09-29 10:23:35 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-09-29 10:23:35 +0000
commite9515d1ee18074928ae1e013dd0ff8666ecbd475 (patch)
tree1150f38a3f9479bdfcfea75d7f3e86a20ada3f2e
parenta71a4e9753bf7a98049b0e8b1793012cfe6da673 (diff)
downloadelgg-e9515d1ee18074928ae1e013dd0ff8666ecbd475.tar.gz
elgg-e9515d1ee18074928ae1e013dd0ff8666ecbd475.tar.bz2
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
-rw-r--r--engine/lib/notification.php32
1 files changed, 16 insertions, 16 deletions
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";