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;
52 $backend = Mail::factory(common_config('mail', 'backend'),
53 common_config('mail', 'params') ?: array());
54 if (PEAR::isError($backend)) {
55 common_server_error($backend->getMessage(), 500);
62 * send an email to one or more recipients
64 * @param array $recipients array of strings with email addresses of recipients
65 * @param array $headers array mapping strings to strings for email headers
66 * @param string $body body of the email
68 * @return boolean success flag
70 function mail_send($recipients, $headers, $body)
73 // XXX: use Mail_Queue... maybe
74 $backend = mail_backend();
76 if (!isset($headers['Content-Type'])) {
77 $headers['Content-Type'] = 'text/plain; charset=UTF-8';
80 assert($backend); // throws an error if it's bad
81 $sent = $backend->send($recipients, $headers, $body);
83 } catch (PEAR_Exception $e) {
86 "Unable to send email - '{$e->getMessage()}'. "
87 . 'Is your mail subsystem set up correctly?'
94 * returns the configured mail domain
96 * Defaults to the server name.
98 * @return string mail domain, suitable for making email addresses.
100 function mail_domain()
102 $maildomain = common_config('mail', 'domain');
104 $maildomain = common_config('site', 'server');
110 * returns a good address for sending email from this server
112 * Uses either the configured value or a faked-up value made
113 * from the mail domain.
115 * @return string notify from address
117 function mail_notify_from()
119 $notifyfrom = common_config('mail', 'notifyfrom');
123 $domain = mail_domain();
125 $notifyfrom = '"'. str_replace('"', '\\"', common_config('site', 'name')) .'" <noreply@'.$domain.'>';
132 * sends email to a user
134 * @param User &$user user to send email to
135 * @param string $subject subject of the email
136 * @param string $body body of the email
137 * @param array $headers optional list of email headers
138 * @param string $address optional specification of email address
140 * @return boolean success flag
142 function mail_to_user(&$user, $subject, $body, $headers=array(), $address=null)
145 $address = $user->email;
148 $recipients = $address;
149 $profile = $user->getProfile();
151 $headers['Date'] = date("r", time());
152 $headers['From'] = mail_notify_from();
153 $headers['To'] = $profile->getBestName() . ' <' . $address . '>';
154 $headers['Subject'] = $subject;
156 return mail_send($recipients, $headers, $body);
160 * Send an email to confirm a user's control of an email address
162 * @param User $user User claiming the email address
163 * @param string $code Confirmation code
164 * @param string $nickname Nickname of user
165 * @param string $address email address to confirm
167 * @see common_confirmation_code()
169 * @return success flag
171 function mail_confirm_address($user, $code, $nickname, $address, $url=null)
174 $url = common_local_url('confirmaddress', array('code' => $code));
177 // TRANS: Subject for address confirmation email.
178 $subject = _('Email address confirmation');
180 // TRANS: Body for address confirmation email.
181 // TRANS: %1$s is the addressed user's nickname, %2$s is the StatusNet sitename,
182 // TRANS: %3$s is the URL to confirm at.
183 $body = sprintf(_("Hey, %1\$s.\n\n".
184 "Someone just entered this email address on %2\$s.\n\n" .
185 "If it was you, and you want to confirm your entry, ".
186 "use the URL below:\n\n\t%3\$s\n\n" .
187 "If not, just ignore this message.\n\n".
188 "Thanks for your time, \n%2\$s\n"),
190 common_config('site', 'name'),
195 return mail_to_user($user, $subject, $body, $headers, $address);
199 * notify a user of subscription by another user
201 * This is just a wrapper around the profile-based version.
203 * @param User $listenee user who is being subscribed to
204 * @param User $listener user who is subscribing
206 * @see mail_subscribe_notify_profile()
210 function mail_subscribe_notify($listenee, $listener)
212 $other = $listener->getProfile();
213 mail_subscribe_notify_profile($listenee, $other);
217 * notify a user of subscription by a profile (remote or local)
219 * This function checks to see if the listenee has an email
220 * address and wants subscription notices.
222 * @param User $listenee user who's being subscribed to
223 * @param Profile $other profile of person who's listening
227 function mail_subscribe_notify_profile($listenee, $other)
229 if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
230 $listenee->email && $listenee->emailnotifysub) {
232 $profile = $listenee->getProfile();
234 $name = $profile->getBestName();
236 $long_name = ($other->fullname) ?
237 ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
239 $recipients = $listenee->email;
241 // use the recipient's localization
242 common_switch_locale($listenee->language);
244 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
245 $headers['From'] = mail_notify_from();
246 $headers['To'] = $name . ' <' . $listenee->email . '>';
247 // TRANS: Subject of new-subscriber notification e-mail.
248 // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
249 $headers['Subject'] = sprintf(_('%1$s is now following you on %2$s.'),
250 $other->getBestName(),
251 common_config('site', 'name'));
253 // TRANS: Main body of new-subscriber notification e-mail.
254 // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
255 $body = sprintf(_('%1$s is now following you on %2$s.'),
257 common_config('site', 'name')) .
258 mail_profile_block($other) .
261 // reset localization
262 common_switch_locale();
263 mail_send($recipients, $headers, $body);
267 function mail_subscribe_pending_notify_profile($listenee, $other)
269 if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
270 $listenee->email && $listenee->emailnotifysub) {
272 $profile = $listenee->getProfile();
274 $name = $profile->getBestName();
276 $long_name = ($other->fullname) ?
277 ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
279 $recipients = $listenee->email;
281 // use the recipient's localization
282 common_switch_locale($listenee->language);
284 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
285 $headers['From'] = mail_notify_from();
286 $headers['To'] = $name . ' <' . $listenee->email . '>';
287 // TRANS: Subject of pending new-subscriber notification e-mail.
288 // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
289 $headers['Subject'] = sprintf(_('%1$s would like to listen to '.
290 'your notices on %2$s.'),
291 $other->getBestName(),
292 common_config('site', 'name'));
294 // TRANS: Main body of pending new-subscriber notification e-mail.
295 // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
296 $body = sprintf(_('%1$s would like to listen to your notices on %2$s. ' .
297 'You may approve or reject their subscription at %3$s'),
299 common_config('site', 'name'),
300 common_local_url('subqueue', array('nickname' => $listenee->nickname))) .
301 mail_profile_block($other) .
304 // reset localization
305 common_switch_locale();
306 mail_send($recipients, $headers, $body);
310 function mail_footer_block()
312 // TRANS: Common footer block for StatusNet notification emails.
313 // TRANS: %1$s is the StatusNet sitename,
314 // TRANS: %2$s is a link to the addressed user's e-mail settings.
315 return "\n\n" . sprintf(_('Faithfully yours,'.
318 "Change your email address or ".
319 "notification options at ".'%2$s'),
320 common_config('site', 'name'),
321 common_local_url('emailsettings')) . "\n";
325 * Format a block of profile info for a plaintext notification email.
327 * @param Profile $profile
330 function mail_profile_block($profile)
333 // TRANS: %1$s is the subscriber's profile URL, %2$s is the subscriber's location (or empty)
334 // TRANS: %3$s is the subscriber's homepage URL (or empty), %4%s is the subscriber's bio (or empty)
338 // TRANS: Profile info line in notification e-mail.
339 // TRANS: %s is a URL.
340 $out[] = sprintf(_("Profile: %s"), $profile->profileurl);
341 if ($profile->location) {
342 // TRANS: Profile info line in notification e-mail.
343 // TRANS: %s is a location.
344 $out[] = sprintf(_("Location: %s"), $profile->location);
346 if ($profile->homepage) {
347 // TRANS: Profile info line in notification e-mail.
348 // TRANS: %s is a homepage.
349 $out[] = sprintf(_("Homepage: %s"), $profile->homepage);
352 // TRANS: Profile info line in notification e-mail.
353 // TRANS: %s is biographical information.
354 $out[] = sprintf(_("Bio: %s"), $profile->bio);
357 $blocklink = common_local_url('block', array('profileid' => $profile->id));
358 // This'll let ModPlus add the remote profile info so it's possible
359 // to block remote users directly...
360 Event::handle('MailProfileInfoBlockLink', array($profile, &$blocklink));
362 // TRANS: This is a paragraph in a new-subscriber e-mail.
363 // TRANS: %s is a URL where the subscriber can be reported as abusive.
364 $out[] = sprintf(_('If you believe this account is being used abusively, ' .
365 'you can block them from your subscribers list and ' .
366 'report as spam to site administrators at %s.'),
370 return implode("\n", $out);
374 * notify a user of their new incoming email address
376 * User's email and incoming fields should already be updated.
378 * @param User $user user with the new address
382 function mail_new_incoming_notify($user)
384 $profile = $user->getProfile();
386 $name = $profile->getBestName();
388 $headers['From'] = $user->incomingemail;
389 $headers['To'] = $name . ' <' . $user->email . '>';
390 // TRANS: Subject of notification mail for new posting email address.
391 // TRANS: %s is the StatusNet sitename.
392 $headers['Subject'] = sprintf(_('New email address for posting to %s'),
393 common_config('site', 'name'));
395 // TRANS: Body of notification mail for new posting email address.
396 // TRANS: %1$s is the StatusNet sitename, %2$s is the e-mail address to send
397 // TRANS: to to post by e-mail, %3$s is a URL to more instructions.
398 $body = sprintf(_("You have a new posting address on %1\$s.\n\n".
399 "Send email to %2\$s to post new messages.\n\n".
400 "More email instructions at %3\$s."),
401 common_config('site', 'name'),
402 $user->incomingemail,
403 common_local_url('doc', array('title' => 'email'))) .
406 mail_send($user->email, $headers, $body);
410 * generate a new address for incoming messages
412 * @todo check the database for uniqueness
414 * @return string new email address for incoming messages
416 function mail_new_incoming_address()
418 $prefix = common_confirmation_code(64);
419 $suffix = mail_domain();
420 return $prefix . '@' . $suffix;
424 * broadcast a notice to all subscribers with SMS notification on
426 * This function sends SMS messages to all users who have sms addresses;
427 * have sms notification on; and have sms enabled for this particular
430 * @param Notice $notice The notice to broadcast
432 * @return success flag
434 function mail_broadcast_notice_sms($notice)
436 // Now, get users subscribed to this profile
440 $UT = common_config('db','type')=='pgsql'?'"user"':'user';
441 $replies = $notice->getReplies();
442 $user->query('SELECT nickname, smsemail, incomingemail ' .
443 "FROM $UT LEFT OUTER JOIN subscription " .
444 "ON $UT.id = subscription.subscriber " .
445 'AND subscription.subscribed = ' . $notice->profile_id . ' ' .
446 'AND subscription.subscribed != subscription.subscriber ' .
447 // Users (other than the sender) who `want SMS notices':
448 "WHERE $UT.id != " . $notice->profile_id . ' ' .
449 "AND $UT.smsemail IS NOT null " .
450 "AND $UT.smsnotify = 1 " .
451 // ... where either the user _is_ subscribed to the sender
452 // (any of the "subscription" fields IS NOT null)
453 // and wants to get SMS for all of this scribe's notices...
454 'AND (subscription.sms = 1 ' .
455 // ... or where the user was mentioned in
456 // or replied-to with the notice:
457 ($replies ? sprintf("OR $UT.id in (%s)",
458 implode(',', $replies))
462 while ($user->fetch()) {
464 'Sending notice ' . $notice->id . ' to ' . $user->smsemail,
466 $success = mail_send_sms_notice_address($notice,
468 $user->incomingemail,
471 // XXX: Not sure, but I think that's the right thing to do
472 common_log(LOG_WARNING,
473 'Sending notice ' . $notice->id . ' to ' .
474 $user->smsemail . ' FAILED, cancelling.',
487 * send a notice to a user via SMS
489 * A convenience wrapper around mail_send_sms_notice_address()
491 * @param Notice $notice notice to send
492 * @param User $user user to receive notice
494 * @see mail_send_sms_notice_address()
496 * @return boolean success flag
498 function mail_send_sms_notice($notice, $user)
500 return mail_send_sms_notice_address($notice,
502 $user->incomingemail,
507 * send a notice to an SMS email address from a given address
509 * We use the user's incoming email address as the "From" address to make
510 * replying to notices easier.
512 * @param Notice $notice notice to send
513 * @param string $smsemail email address to send to
514 * @param string $incomingemail email address to set as 'from'
515 * @param string $nickname nickname to add to beginning
517 * @return boolean success flag
519 function mail_send_sms_notice_address($notice, $smsemail, $incomingemail, $nickname)
521 $to = $nickname . ' <' . $smsemail . '>';
523 $other = $notice->getProfile();
525 common_log(LOG_INFO, 'Sending notice ' . $notice->id .
526 ' to ' . $smsemail, __FILE__);
530 $headers['From'] = ($incomingemail) ? $incomingemail : mail_notify_from();
531 $headers['To'] = $to;
532 // TRANS: Subject line for SMS-by-email notification messages.
533 // TRANS: %s is the posting user's nickname.
534 $headers['Subject'] = sprintf(_('%s status'),
535 $other->getBestName());
537 $body = $notice->content;
539 return mail_send($smsemail, $headers, $body);
543 * send a message to confirm a claim for an SMS number
545 * @param string $code confirmation code
546 * @param string $nickname nickname of user claiming number
547 * @param string $address email address to send the confirmation to
549 * @see common_confirmation_code()
553 function mail_confirm_sms($code, $nickname, $address)
555 $recipients = $address;
557 $headers['From'] = mail_notify_from();
558 $headers['To'] = $nickname . ' <' . $address . '>';
559 // TRANS: Subject line for SMS-by-email address confirmation message.
560 $headers['Subject'] = _('SMS confirmation');
562 // TRANS: Main body heading for SMS-by-email address confirmation message.
563 // TRANS: %s is the addressed user's nickname.
564 $body = sprintf(_('%s: confirm you own this phone number with this code:'), $nickname);
569 mail_send($recipients, $headers, $body);
573 * send a mail message to notify a user of a 'nudge'
575 * @param User $from user nudging
576 * @param User $to user being nudged
578 * @return boolean success flag
580 function mail_notify_nudge($from, $to)
582 common_switch_locale($to->language);
583 // TRANS: Subject for 'nudge' notification email.
584 // TRANS: %s is the nudging user.
585 $subject = sprintf(_('You have been nudged by %s'), $from->nickname);
587 $from_profile = $from->getProfile();
589 // TRANS: Body for 'nudge' notification email.
590 // TRANS: %1$s is the nuding user's long name, $2$s is the nudging user's nickname,
591 // TRANS: %3$s is a URL to post notices at.
592 $body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to ".
593 "these days and is inviting you to post some news.\n\n".
594 "So let's hear from you :)\n\n".
596 "Don't reply to this email; it won't get to them."),
597 $from_profile->getBestName(),
599 common_local_url('all', array('nickname' => $to->nickname))) .
601 common_switch_locale();
603 $headers = _mail_prepare_headers('nudge', $to->nickname, $from->nickname);
605 return mail_to_user($to, $subject, $body, $headers);
609 * send a message to notify a user of a direct message (DM)
611 * This function checks to see if the recipient wants notification
612 * of DMs and has a configured email address.
614 * @param Message $message message to notify about
615 * @param User $from user sending message; default to sender
616 * @param User $to user receiving message; default to recipient
618 * @return boolean success code
620 function mail_notify_message($message, $from=null, $to=null)
622 if (is_null($from)) {
623 $from = User::getKV('id', $message->from_profile);
627 $to = User::getKV('id', $message->to_profile);
630 if (is_null($to->email) || !$to->emailnotifymsg) {
634 common_switch_locale($to->language);
635 // TRANS: Subject for direct-message notification email.
636 // TRANS: %s is the sending user's nickname.
637 $subject = sprintf(_('New private message from %s'), $from->nickname);
639 $from_profile = $from->getProfile();
641 // TRANS: Body for direct-message notification email.
642 // TRANS: %1$s is the sending user's long name, %2$s is the sending user's nickname,
643 // TRANS: %3$s is the message content, %4$s a URL to the message,
644 $body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
645 "------------------------------------------------------\n".
647 "------------------------------------------------------\n\n".
648 "You can reply to their message here:\n\n".
650 "Don't reply to this email; it won't get to them."),
651 $from_profile->getBestName(),
654 common_local_url('newmessage', array('to' => $from->id))) .
657 $headers = _mail_prepare_headers('message', $to->nickname, $from->nickname);
659 common_switch_locale();
660 return mail_to_user($to, $subject, $body, $headers);
664 * Notify a user that they have received an "attn:" message AKA "@-reply"
666 * @param User $user The user who recevied the notice
667 * @param Notice $notice The notice that was sent
671 function mail_notify_attn($user, $notice)
673 if (!$user->receivesEmailNotifications()) {
677 $sender = $notice->getProfile();
679 if ($sender->id == $user->id) {
683 // See if the notice's author who mentions this user is sandboxed
684 if (!$sender->hasRight(Right::EMAILONREPLY)) {
688 // If the author has blocked the author, don't spam them with a notification.
689 if ($user->hasBlocked($sender)) {
693 $bestname = $sender->getBestName();
695 common_switch_locale($user->language);
697 if ($notice->hasConversation()) {
698 $conversationUrl = common_local_url('conversation',
699 array('id' => $notice->conversation)).'#notice-'.$notice->id;
700 // TRANS: Line in @-reply notification e-mail. %s is conversation URL.
701 $conversationEmailText = sprintf(_("The full conversation can be read here:\n\n".
702 "\t%s"), $conversationUrl) . "\n\n";
704 $conversationEmailText = '';
707 // TRANS: E-mail subject for notice notification.
708 // TRANS: %1$s is the sending user's long name, %2$s is the adding user's nickname.
709 $subject = sprintf(_('%1$s (@%2$s) sent a notice to your attention'), $bestname, $sender->nickname);
711 // TRANS: Body of @-reply notification e-mail.
712 // TRANS: %1$s is the sending user's name, $2$s is the StatusNet sitename,
713 // TRANS: %3$s is a URL to the notice, %4$s is the notice text,
714 // 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),
715 // TRANS: %6$s is a URL to reply to the notice, %7$s is a URL to all @-replies for the addressed user,
716 $body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
717 "The notice is here:\n\n".
722 "You can reply back here:\n\n".
724 "The list of all @-replies for you here:\n\n" .
726 $sender->getFancyName(),//%1
727 common_config('site', 'name'),//%2
728 common_local_url('shownotice',
729 array('notice' => $notice->id)),//%3
730 $notice->content,//%4
731 $conversationEmailText,//%5
732 common_local_url('newnotice',
733 array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
734 common_local_url('replies',
735 array('nickname' => $user->nickname))) . //%7
737 $headers = _mail_prepare_headers('mention', $user->nickname, $sender->nickname);
739 common_switch_locale();
740 mail_to_user($user, $subject, $body, $headers);
744 * Prepare the common mail headers used in notification emails
746 * @param string $msg_type type of message being sent to the user
747 * @param string $to nickname of the receipient
748 * @param string $from nickname of the user triggering the notification
750 * @return array list of mail headers to include in the message
752 function _mail_prepare_headers($msg_type, $to, $from)
755 'X-StatusNet-MessageType' => $msg_type,
756 'X-StatusNet-TargetUser' => $to,
757 'X-StatusNet-SourceUser' => $from,
758 'X-StatusNet-Domain' => common_config('site', 'server')
765 * Send notification emails to group administrator.
767 * @param User_group $group
768 * @param Profile $joiner
770 function mail_notify_group_join($group, $joiner)
772 // This returns a Profile query...
773 $admin = $group->getAdmins();
774 while ($admin->fetch()) {
775 // We need a local user for email notifications...
776 $adminUser = User::getKV('id', $admin->id);
777 // @fixme check for email preference?
778 if ($adminUser && $adminUser->email) {
779 // use the recipient's localization
780 common_switch_locale($adminUser->language);
782 $headers = _mail_prepare_headers('join', $admin->nickname, $joiner->nickname);
783 $headers['From'] = mail_notify_from();
784 $headers['To'] = $admin->getBestName() . ' <' . $adminUser->email . '>';
785 // TRANS: Subject of group join notification e-mail.
786 // TRANS: %1$s is the joining user's nickname, %2$s is the group name, and %3$s is the StatusNet sitename.
787 $headers['Subject'] = sprintf(_('%1$s has joined '.
788 'your group %2$s on %3$s'),
789 $joiner->getBestName(),
790 $group->getBestName(),
791 common_config('site', 'name'));
793 // TRANS: Main body of group join notification e-mail.
794 // TRANS: %1$s is the subscriber's long name, %2$s is the group name, and %3$s is the StatusNet sitename,
795 // TRANS: %4$s is a block of profile info about the subscriber.
796 // TRANS: %5$s is a link to the addressed user's e-mail settings.
797 $body = sprintf(_('%1$s has joined your group %2$s on %3$s.'),
798 $joiner->getFancyName(),
799 $group->getFancyName(),
800 common_config('site', 'name')) .
801 mail_profile_block($joiner) .
804 // reset localization
805 common_switch_locale();
806 mail_send($adminUser->email, $headers, $body);
813 * Send notification emails to group administrator.
815 * @param User_group $group
816 * @param Profile $joiner
818 function mail_notify_group_join_pending($group, $joiner)
820 $admin = $group->getAdmins();
821 while ($admin->fetch()) {
822 // We need a local user for email notifications...
823 $adminUser = User::getKV('id', $admin->id);
824 // @fixme check for email preference?
825 if ($adminUser && $adminUser->email) {
826 // use the recipient's localization
827 common_switch_locale($adminUser->language);
829 $headers = _mail_prepare_headers('join', $admin->nickname, $joiner->nickname);
830 $headers['From'] = mail_notify_from();
831 $headers['To'] = $admin->getBestName() . ' <' . $adminUser->email . '>';
832 // TRANS: Subject of pending group join request notification e-mail.
833 // TRANS: %1$s is the joining user's nickname, %2$s is the group name, and %3$s is the StatusNet sitename.
834 $headers['Subject'] = sprintf(_('%1$s wants to join your group %2$s on %3$s.'),
835 $joiner->getBestName(),
836 $group->getBestName(),
837 common_config('site', 'name'));
839 // TRANS: Main body of pending group join request notification e-mail.
840 // TRANS: %1$s is the subscriber's long name, %2$s is the group name, and %3$s is the StatusNet sitename,
841 // TRANS: %4$s is the URL to the moderation queue page.
842 $body = sprintf(_('%1$s would like to join your group %2$s on %3$s. ' .
843 'You may approve or reject their group membership at %4$s'),
844 $joiner->getFancyName(),
845 $group->getFancyName(),
846 common_config('site', 'name'),
847 common_local_url('groupqueue', array('nickname' => $group->nickname))) .
848 mail_profile_block($joiner) .
851 // reset localization
852 common_switch_locale();
853 mail_send($adminUser->email, $headers, $body);