3 * StatusNet, the distributed open-source microblogging tool
5 * utilities for sending email
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @author Zach Copley <zach@status.net>
26 * @author Robin Millette <millette@status.net>
27 * @author Sarven Capadisli <csarven@status.net>
28 * @copyright 2008 StatusNet, Inc.
29 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
30 * @link http://status.net/
33 if (!defined('STATUSNET') && !defined('LACONICA')) {
37 require_once 'Mail.php';
40 * return the configured mail backend
42 * Uses the $config array to make a mail backend. Cached so it is safe to call
45 * @return Mail backend
47 function mail_backend()
49 static $backend = null;
54 $backend = $mail->factory(common_config('mail', 'backend'),
55 common_config('mail', 'params') ?: array());
56 if ($_PEAR->isError($backend)) {
57 throw new ServerException($backend->getMessage());
64 * send an email to one or more recipients
66 * @param array $recipients array of strings with email addresses of recipients
67 * @param array $headers array mapping strings to strings for email headers
68 * @param string $body body of the email
70 * @return boolean success flag
72 function mail_send($recipients, $headers, $body)
77 // XXX: use Mail_Queue... maybe
78 $backend = mail_backend();
80 if (!isset($headers['Content-Type'])) {
81 $headers['Content-Type'] = 'text/plain; charset=UTF-8';
84 assert($backend); // throws an error if it's bad
85 $sent = $backend->send($recipients, $headers, $body);
86 if ($_PEAR->isError($sent)) {
87 throw new ServerException($sent->getMessage());
90 } catch (PEAR_Exception $e) {
93 "Unable to send email - '{$e->getMessage()}'. "
94 . 'Is your mail subsystem set up correctly?'
101 * returns the configured mail domain
103 * Defaults to the server name.
105 * @return string mail domain, suitable for making email addresses.
107 function mail_domain()
109 $maildomain = common_config('mail', 'domain');
111 $maildomain = common_config('site', 'server');
117 * returns a good address for sending email from this server
119 * Uses either the configured value or a faked-up value made
120 * from the mail domain.
122 * @return string notify from address
124 function mail_notify_from()
126 $notifyfrom = common_config('mail', 'notifyfrom');
130 $domain = mail_domain();
132 $notifyfrom = '"'. str_replace('"', '\\"', common_config('site', 'name')) .'" <noreply@'.$domain.'>';
139 * sends email to a user
141 * @param User &$user user to send email to
142 * @param string $subject subject of the email
143 * @param string $body body of the email
144 * @param array $headers optional list of email headers
145 * @param string $address optional specification of email address
147 * @return boolean success flag
149 function mail_to_user(&$user, $subject, $body, $headers=array(), $address=null)
152 $address = $user->email;
155 $recipients = $address;
156 $profile = $user->getProfile();
158 $headers['Date'] = date("r", time());
159 $headers['From'] = mail_notify_from();
160 $headers['To'] = $profile->getBestName() . ' <' . $address . '>';
161 $headers['Subject'] = $subject;
163 return mail_send($recipients, $headers, $body);
167 * Send an email to confirm a user's control of an email address
169 * @param User $user User claiming the email address
170 * @param string $code Confirmation code
171 * @param string $nickname Nickname of user
172 * @param string $address email address to confirm
174 * @see common_confirmation_code()
176 * @return success flag
178 function mail_confirm_address($user, $code, $nickname, $address, $url=null)
181 $url = common_local_url('confirmaddress', array('code' => $code));
184 // TRANS: Subject for address confirmation email.
185 $subject = _('Email address confirmation');
187 // TRANS: Body for address confirmation email.
188 // TRANS: %1$s is the addressed user's nickname, %2$s is the StatusNet sitename,
189 // TRANS: %3$s is the URL to confirm at.
190 $body = sprintf(_("Hey, %1\$s.\n\n".
191 "Someone just entered this email address on %2\$s.\n\n" .
192 "If it was you, and you want to confirm your entry, ".
193 "use the URL below:\n\n\t%3\$s\n\n" .
194 "If not, just ignore this message.\n\n".
195 "Thanks for your time, \n%2\$s\n"),
197 common_config('site', 'name'),
202 return mail_to_user($user, $subject, $body, $headers, $address);
206 * notify a user of subscription by another user
208 * This is just a wrapper around the profile-based version.
210 * @param User $listenee user who is being subscribed to
211 * @param User $listener user who is subscribing
213 * @see mail_subscribe_notify_profile()
217 function mail_subscribe_notify($listenee, $listener)
219 $other = $listener->getProfile();
220 mail_subscribe_notify_profile($listenee, $other);
224 * notify a user of subscription by a profile (remote or local)
226 * This function checks to see if the listenee has an email
227 * address and wants subscription notices.
229 * @param User $listenee user who's being subscribed to
230 * @param Profile $other profile of person who's listening
234 function mail_subscribe_notify_profile($listenee, $other)
236 if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
237 $listenee->email && $listenee->emailnotifysub) {
239 $profile = $listenee->getProfile();
241 $name = $profile->getBestName();
243 $long_name = ($other->fullname) ?
244 ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
246 $recipients = $listenee->email;
248 // use the recipient's localization
249 common_switch_locale($listenee->language);
251 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
252 $headers['From'] = mail_notify_from();
253 $headers['To'] = $name . ' <' . $listenee->email . '>';
254 // TRANS: Subject of new-subscriber notification e-mail.
255 // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
256 $headers['Subject'] = sprintf(_('%1$s is now following you on %2$s.'),
257 $other->getBestName(),
258 common_config('site', 'name'));
260 // TRANS: Main body of new-subscriber notification e-mail.
261 // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
262 $body = sprintf(_('%1$s is now following you on %2$s.'),
264 common_config('site', 'name')) .
265 mail_profile_block($other) .
268 // reset localization
269 common_switch_locale();
270 mail_send($recipients, $headers, $body);
274 function mail_subscribe_pending_notify_profile($listenee, $other)
276 if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
277 $listenee->email && $listenee->emailnotifysub) {
279 $profile = $listenee->getProfile();
281 $name = $profile->getBestName();
283 $long_name = ($other->fullname) ?
284 ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
286 $recipients = $listenee->email;
288 // use the recipient's localization
289 common_switch_locale($listenee->language);
291 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
292 $headers['From'] = mail_notify_from();
293 $headers['To'] = $name . ' <' . $listenee->email . '>';
294 // TRANS: Subject of pending new-subscriber notification e-mail.
295 // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
296 $headers['Subject'] = sprintf(_('%1$s would like to listen to '.
297 'your notices on %2$s.'),
298 $other->getBestName(),
299 common_config('site', 'name'));
301 // TRANS: Main body of pending new-subscriber notification e-mail.
302 // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
303 $body = sprintf(_('%1$s would like to listen to your notices on %2$s. ' .
304 'You may approve or reject their subscription at %3$s'),
306 common_config('site', 'name'),
307 common_local_url('subqueue', array('nickname' => $listenee->nickname))) .
308 mail_profile_block($other) .
311 // reset localization
312 common_switch_locale();
313 mail_send($recipients, $headers, $body);
317 function mail_footer_block()
319 // TRANS: Common footer block for StatusNet notification emails.
320 // TRANS: %1$s is the StatusNet sitename,
321 // TRANS: %2$s is a link to the addressed user's e-mail settings.
322 return "\n\n" . sprintf(_('Faithfully yours,'.
325 "Change your email address or ".
326 "notification options at ".'%2$s'),
327 common_config('site', 'name'),
328 common_local_url('emailsettings')) . "\n";
332 * Format a block of profile info for a plaintext notification email.
334 * @param Profile $profile
337 function mail_profile_block($profile)
340 // TRANS: %1$s is the subscriber's profile URL, %2$s is the subscriber's location (or empty)
341 // TRANS: %3$s is the subscriber's homepage URL (or empty), %4%s is the subscriber's bio (or empty)
345 // TRANS: Profile info line in notification e-mail.
346 // TRANS: %s is a URL.
347 $out[] = sprintf(_("Profile: %s"), $profile->profileurl);
348 if ($profile->location) {
349 // TRANS: Profile info line in notification e-mail.
350 // TRANS: %s is a location.
351 $out[] = sprintf(_("Location: %s"), $profile->location);
353 if ($profile->homepage) {
354 // TRANS: Profile info line in notification e-mail.
355 // TRANS: %s is a homepage.
356 $out[] = sprintf(_("Homepage: %s"), $profile->homepage);
359 // TRANS: Profile info line in notification e-mail.
360 // TRANS: %s is biographical information.
361 $out[] = sprintf(_("Bio: %s"), $profile->bio);
364 $blocklink = common_local_url('block', array('profileid' => $profile->id));
365 // This'll let ModPlus add the remote profile info so it's possible
366 // to block remote users directly...
367 Event::handle('MailProfileInfoBlockLink', array($profile, &$blocklink));
369 // TRANS: This is a paragraph in a new-subscriber e-mail.
370 // TRANS: %s is a URL where the subscriber can be reported as abusive.
371 $out[] = sprintf(_('If you believe this account is being used abusively, ' .
372 'you can block them from your subscribers list and ' .
373 'report as spam to site administrators at %s.'),
377 return implode("\n", $out);
381 * notify a user of their new incoming email address
383 * User's email and incoming fields should already be updated.
385 * @param User $user user with the new address
389 function mail_new_incoming_notify($user)
391 $profile = $user->getProfile();
393 $name = $profile->getBestName();
395 $headers['From'] = $user->incomingemail;
396 $headers['To'] = $name . ' <' . $user->email . '>';
397 // TRANS: Subject of notification mail for new posting email address.
398 // TRANS: %s is the StatusNet sitename.
399 $headers['Subject'] = sprintf(_('New email address for posting to %s'),
400 common_config('site', 'name'));
402 // TRANS: Body of notification mail for new posting email address.
403 // TRANS: %1$s is the StatusNet sitename, %2$s is the e-mail address to send
404 // TRANS: to to post by e-mail, %3$s is a URL to more instructions.
405 $body = sprintf(_("You have a new posting address on %1\$s.\n\n".
406 "Send email to %2\$s to post new messages.\n\n".
407 "More email instructions at %3\$s."),
408 common_config('site', 'name'),
409 $user->incomingemail,
410 common_local_url('doc', array('title' => 'email'))) .
413 mail_send($user->email, $headers, $body);
417 * generate a new address for incoming messages
419 * @todo check the database for uniqueness
421 * @return string new email address for incoming messages
423 function mail_new_incoming_address()
425 $prefix = common_confirmation_code(64);
426 $suffix = mail_domain();
427 return $prefix . '@' . $suffix;
431 * broadcast a notice to all subscribers with SMS notification on
433 * This function sends SMS messages to all users who have sms addresses;
434 * have sms notification on; and have sms enabled for this particular
437 * @param Notice $notice The notice to broadcast
439 * @return success flag
441 function mail_broadcast_notice_sms($notice)
443 // Now, get users subscribed to this profile
447 $UT = common_config('db','type')=='pgsql'?'"user"':'user';
448 $replies = $notice->getReplies();
449 $user->query('SELECT nickname, smsemail, incomingemail ' .
450 "FROM $UT LEFT OUTER JOIN subscription " .
451 "ON $UT.id = subscription.subscriber " .
452 'AND subscription.subscribed = ' . $notice->profile_id . ' ' .
453 'AND subscription.subscribed != subscription.subscriber ' .
454 // Users (other than the sender) who `want SMS notices':
455 "WHERE $UT.id != " . $notice->profile_id . ' ' .
456 "AND $UT.smsemail IS NOT null " .
457 "AND $UT.smsnotify = 1 " .
458 // ... where either the user _is_ subscribed to the sender
459 // (any of the "subscription" fields IS NOT null)
460 // and wants to get SMS for all of this scribe's notices...
461 'AND (subscription.sms = 1 ' .
462 // ... or where the user was mentioned in
463 // or replied-to with the notice:
464 ($replies ? sprintf("OR $UT.id in (%s)",
465 implode(',', $replies))
469 while ($user->fetch()) {
471 'Sending notice ' . $notice->id . ' to ' . $user->smsemail,
473 $success = mail_send_sms_notice_address($notice,
475 $user->incomingemail,
478 // XXX: Not sure, but I think that's the right thing to do
479 common_log(LOG_WARNING,
480 'Sending notice ' . $notice->id . ' to ' .
481 $user->smsemail . ' FAILED, cancelling.',
494 * send a notice to a user via SMS
496 * A convenience wrapper around mail_send_sms_notice_address()
498 * @param Notice $notice notice to send
499 * @param User $user user to receive notice
501 * @see mail_send_sms_notice_address()
503 * @return boolean success flag
505 function mail_send_sms_notice($notice, $user)
507 return mail_send_sms_notice_address($notice,
509 $user->incomingemail,
514 * send a notice to an SMS email address from a given address
516 * We use the user's incoming email address as the "From" address to make
517 * replying to notices easier.
519 * @param Notice $notice notice to send
520 * @param string $smsemail email address to send to
521 * @param string $incomingemail email address to set as 'from'
522 * @param string $nickname nickname to add to beginning
524 * @return boolean success flag
526 function mail_send_sms_notice_address($notice, $smsemail, $incomingemail, $nickname)
528 $to = $nickname . ' <' . $smsemail . '>';
530 $other = $notice->getProfile();
532 common_log(LOG_INFO, 'Sending notice ' . $notice->id .
533 ' to ' . $smsemail, __FILE__);
537 $headers['From'] = ($incomingemail) ? $incomingemail : mail_notify_from();
538 $headers['To'] = $to;
539 // TRANS: Subject line for SMS-by-email notification messages.
540 // TRANS: %s is the posting user's nickname.
541 $headers['Subject'] = sprintf(_('%s status'),
542 $other->getBestName());
544 $body = $notice->content;
546 return mail_send($smsemail, $headers, $body);
550 * send a message to confirm a claim for an SMS number
552 * @param string $code confirmation code
553 * @param string $nickname nickname of user claiming number
554 * @param string $address email address to send the confirmation to
556 * @see common_confirmation_code()
560 function mail_confirm_sms($code, $nickname, $address)
562 $recipients = $address;
564 $headers['From'] = mail_notify_from();
565 $headers['To'] = $nickname . ' <' . $address . '>';
566 // TRANS: Subject line for SMS-by-email address confirmation message.
567 $headers['Subject'] = _('SMS confirmation');
569 // TRANS: Main body heading for SMS-by-email address confirmation message.
570 // TRANS: %s is the addressed user's nickname.
571 $body = sprintf(_('%s: confirm you own this phone number with this code:'), $nickname);
576 mail_send($recipients, $headers, $body);
580 * send a mail message to notify a user of a 'nudge'
582 * @param User $from user nudging
583 * @param User $to user being nudged
585 * @return boolean success flag
587 function mail_notify_nudge($from, $to)
589 common_switch_locale($to->language);
590 // TRANS: Subject for 'nudge' notification email.
591 // TRANS: %s is the nudging user.
592 $subject = sprintf(_('You have been nudged by %s'), $from->nickname);
594 $from_profile = $from->getProfile();
596 // TRANS: Body for 'nudge' notification email.
597 // TRANS: %1$s is the nuding user's long name, $2$s is the nudging user's nickname,
598 // TRANS: %3$s is a URL to post notices at.
599 $body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to ".
600 "these days and is inviting you to post some news.\n\n".
601 "So let's hear from you :)\n\n".
603 "Don't reply to this email; it won't get to them."),
604 $from_profile->getBestName(),
606 common_local_url('all', array('nickname' => $to->nickname))) .
608 common_switch_locale();
610 $headers = _mail_prepare_headers('nudge', $to->nickname, $from->nickname);
612 return mail_to_user($to, $subject, $body, $headers);
616 * send a message to notify a user of a direct message (DM)
618 * This function checks to see if the recipient wants notification
619 * of DMs and has a configured email address.
621 * @param Message $message message to notify about
622 * @param User $from user sending message; default to sender
623 * @param User $to user receiving message; default to recipient
625 * @return boolean success code
627 function mail_notify_message($message, $from=null, $to=null)
629 if (is_null($from)) {
630 $from = User::getKV('id', $message->from_profile);
634 $to = User::getKV('id', $message->to_profile);
637 if (is_null($to->email) || !$to->emailnotifymsg) {
641 common_switch_locale($to->language);
642 // TRANS: Subject for direct-message notification email.
643 // TRANS: %s is the sending user's nickname.
644 $subject = sprintf(_('New private message from %s'), $from->nickname);
646 $from_profile = $from->getProfile();
648 // TRANS: Body for direct-message notification email.
649 // TRANS: %1$s is the sending user's long name, %2$s is the sending user's nickname,
650 // TRANS: %3$s is the message content, %4$s a URL to the message,
651 $body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
652 "------------------------------------------------------\n".
654 "------------------------------------------------------\n\n".
655 "You can reply to their message here:\n\n".
657 "Don't reply to this email; it won't get to them."),
658 $from_profile->getBestName(),
661 common_local_url('newmessage', array('to' => $from->id))) .
664 $headers = _mail_prepare_headers('message', $to->nickname, $from->nickname);
666 common_switch_locale();
667 return mail_to_user($to, $subject, $body, $headers);
671 * Notify a user that they have received an "attn:" message AKA "@-reply"
673 * @param User $user The user who recevied the notice
674 * @param Notice $notice The notice that was sent
678 function mail_notify_attn($user, $notice)
680 if (!$user->receivesEmailNotifications()) {
684 $sender = $notice->getProfile();
686 if ($sender->id == $user->id) {
690 // See if the notice's author who mentions this user is sandboxed
691 if (!$sender->hasRight(Right::EMAILONREPLY)) {
695 // If the author has blocked the author, don't spam them with a notification.
696 if ($user->hasBlocked($sender)) {
700 $bestname = $sender->getBestName();
702 common_switch_locale($user->language);
704 if ($notice->hasConversation()) {
705 $conversationUrl = common_local_url('conversation',
706 array('id' => $notice->conversation)).'#notice-'.$notice->id;
707 // TRANS: Line in @-reply notification e-mail. %s is conversation URL.
708 $conversationEmailText = sprintf(_("The full conversation can be read here:\n\n".
709 "\t%s"), $conversationUrl) . "\n\n";
711 $conversationEmailText = '';
714 // TRANS: E-mail subject for notice notification.
715 // TRANS: %1$s is the sending user's long name, %2$s is the adding user's nickname.
716 $subject = sprintf(_('%1$s (@%2$s) sent a notice to your attention'), $bestname, $sender->nickname);
718 // TRANS: Body of @-reply notification e-mail.
719 // TRANS: %1$s is the sending user's name, $2$s is the StatusNet sitename,
720 // TRANS: %3$s is a URL to the notice, %4$s is the notice text,
721 // TRANS: %5$s is the text "The full conversation can be read here:" and a URL to the full conversion if it exists (otherwise empty),
722 // TRANS: %6$s is a URL to reply to the notice, %7$s is a URL to all @-replies for the addressed user,
723 $body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
724 "The notice is here:\n\n".
729 "You can reply back here:\n\n".
731 "The list of all @-replies for you here:\n\n" .
733 $sender->getFancyName(),//%1
734 common_config('site', 'name'),//%2
735 common_local_url('shownotice',
736 array('notice' => $notice->id)),//%3
737 $notice->content,//%4
738 $conversationEmailText,//%5
739 common_local_url('newnotice',
740 array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
741 common_local_url('replies',
742 array('nickname' => $user->nickname))) . //%7
744 $headers = _mail_prepare_headers('mention', $user->nickname, $sender->nickname);
746 common_switch_locale();
747 mail_to_user($user, $subject, $body, $headers);
751 * Prepare the common mail headers used in notification emails
753 * @param string $msg_type type of message being sent to the user
754 * @param string $to nickname of the receipient
755 * @param string $from nickname of the user triggering the notification
757 * @return array list of mail headers to include in the message
759 function _mail_prepare_headers($msg_type, $to, $from)
762 'X-StatusNet-MessageType' => $msg_type,
763 'X-StatusNet-TargetUser' => $to,
764 'X-StatusNet-SourceUser' => $from,
765 'X-StatusNet-Domain' => common_config('site', 'server')
772 * Send notification emails to group administrator.
774 * @param User_group $group
775 * @param Profile $joiner
777 function mail_notify_group_join($group, $joiner)
779 // This returns a Profile query...
780 $admin = $group->getAdmins();
781 while ($admin->fetch()) {
782 // We need a local user for email notifications...
783 $adminUser = User::getKV('id', $admin->id);
784 // @fixme check for email preference?
785 if ($adminUser && $adminUser->email) {
786 // use the recipient's localization
787 common_switch_locale($adminUser->language);
789 $headers = _mail_prepare_headers('join', $admin->nickname, $joiner->nickname);
790 $headers['From'] = mail_notify_from();
791 $headers['To'] = $admin->getBestName() . ' <' . $adminUser->email . '>';
792 // TRANS: Subject of group join notification e-mail.
793 // TRANS: %1$s is the joining user's nickname, %2$s is the group name, and %3$s is the StatusNet sitename.
794 $headers['Subject'] = sprintf(_('%1$s has joined '.
795 'your group %2$s on %3$s'),
796 $joiner->getBestName(),
797 $group->getBestName(),
798 common_config('site', 'name'));
800 // TRANS: Main body of group join notification e-mail.
801 // TRANS: %1$s is the subscriber's long name, %2$s is the group name, and %3$s is the StatusNet sitename,
802 // TRANS: %4$s is a block of profile info about the subscriber.
803 // TRANS: %5$s is a link to the addressed user's e-mail settings.
804 $body = sprintf(_('%1$s has joined your group %2$s on %3$s.'),
805 $joiner->getFancyName(),
806 $group->getFancyName(),
807 common_config('site', 'name')) .
808 mail_profile_block($joiner) .
811 // reset localization
812 common_switch_locale();
813 mail_send($adminUser->email, $headers, $body);
820 * Send notification emails to group administrator.
822 * @param User_group $group
823 * @param Profile $joiner
825 function mail_notify_group_join_pending($group, $joiner)
827 $admin = $group->getAdmins();
828 while ($admin->fetch()) {
829 // We need a local user for email notifications...
830 $adminUser = User::getKV('id', $admin->id);
831 // @fixme check for email preference?
832 if ($adminUser && $adminUser->email) {
833 // use the recipient's localization
834 common_switch_locale($adminUser->language);
836 $headers = _mail_prepare_headers('join', $admin->nickname, $joiner->nickname);
837 $headers['From'] = mail_notify_from();
838 $headers['To'] = $admin->getBestName() . ' <' . $adminUser->email . '>';
839 // TRANS: Subject of pending group join request notification e-mail.
840 // TRANS: %1$s is the joining user's nickname, %2$s is the group name, and %3$s is the StatusNet sitename.
841 $headers['Subject'] = sprintf(_('%1$s wants to join your group %2$s on %3$s.'),
842 $joiner->getBestName(),
843 $group->getBestName(),
844 common_config('site', 'name'));
846 // TRANS: Main body of pending group join request notification e-mail.
847 // TRANS: %1$s is the subscriber's long name, %2$s is the group name, and %3$s is the StatusNet sitename,
848 // TRANS: %4$s is the URL to the moderation queue page.
849 $body = sprintf(_('%1$s would like to join your group %2$s on %3$s. ' .
850 'You may approve or reject their group membership at %4$s'),
851 $joiner->getFancyName(),
852 $group->getFancyName(),
853 common_config('site', 'name'),
854 common_local_url('groupqueue', array('nickname' => $group->nickname))) .
855 mail_profile_block($joiner) .
858 // reset localization
859 common_switch_locale();
860 mail_send($adminUser->email, $headers, $body);