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('GNUSOCIAL')) { exit(1); }
35 require_once 'Mail.php';
38 * return the configured mail backend
40 * Uses the $config array to make a mail backend. Cached so it is safe to call
43 * @return Mail backend
45 function mail_backend()
47 static $backend = null;
52 $backend = $mail->factory(common_config('mail', 'backend'),
53 common_config('mail', 'params') ?: array());
54 if ($_PEAR->isError($backend)) {
55 throw new EmailException($backend->getMessage(), $backend->getCode());
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)
75 // XXX: use Mail_Queue... maybe
76 $backend = mail_backend();
78 if (!isset($headers['Content-Type'])) {
79 $headers['Content-Type'] = 'text/plain; charset=UTF-8';
82 assert($backend); // throws an error if it's bad
83 $sent = $backend->send($recipients, $headers, $body);
84 if ($_PEAR->isError($sent)) {
85 throw new EmailException($sent->getMessage(), $sent->getCode());
88 } catch (PEAR_Exception $e) {
91 "Unable to send email - '{$e->getMessage()}'. "
92 . 'Is your mail subsystem set up correctly?'
99 * returns the configured mail domain
101 * Defaults to the server name.
103 * @return string mail domain, suitable for making email addresses.
105 function mail_domain()
107 $maildomain = common_config('mail', 'domain');
109 $maildomain = common_config('site', 'server');
115 * returns a good address for sending email from this server
117 * Uses either the configured value or a faked-up value made
118 * from the mail domain.
120 * @return string notify from address
122 function mail_notify_from()
124 $notifyfrom = common_config('mail', 'notifyfrom');
128 $domain = mail_domain();
130 $notifyfrom = '"'. str_replace('"', '\\"', common_config('site', 'name')) .'" <noreply@'.$domain.'>';
137 * sends email to a user
139 * @param User &$user user to send email to
140 * @param string $subject subject of the email
141 * @param string $body body of the email
142 * @param array $headers optional list of email headers
143 * @param string $address optional specification of email address
145 * @return boolean success flag
147 function mail_to_user(&$user, $subject, $body, $headers=array(), $address=null)
150 $address = $user->email;
153 $recipients = $address;
154 $profile = $user->getProfile();
156 $headers['Date'] = date("r", time());
157 $headers['From'] = mail_notify_from();
158 $headers['To'] = $profile->getBestName() . ' <' . $address . '>';
159 $headers['Subject'] = $subject;
161 return mail_send($recipients, $headers, $body);
165 * Send an email to confirm a user's control of an email address
167 * @param User $user User claiming the email address
168 * @param string $code Confirmation code
169 * @param string $nickname Nickname of user
170 * @param string $address email address to confirm
172 * @see common_confirmation_code()
174 * @return success flag
176 function mail_confirm_address($user, $code, $nickname, $address, $url=null)
179 $url = common_local_url('confirmaddress', array('code' => $code));
182 // TRANS: Subject for address confirmation email.
183 $subject = _('Email address confirmation');
185 // TRANS: Body for address confirmation email.
186 // TRANS: %1$s is the addressed user's nickname, %2$s is the StatusNet sitename,
187 // TRANS: %3$s is the URL to confirm at.
188 $body = sprintf(_("Hey, %1\$s.\n\n".
189 "Someone just entered this email address on %2\$s.\n\n" .
190 "If it was you, and you want to confirm your entry, ".
191 "use the URL below:\n\n\t%3\$s\n\n" .
192 "If not, just ignore this message.\n\n".
193 "Thanks for your time, \n%2\$s\n"),
195 common_config('site', 'name'),
200 return mail_to_user($user, $subject, $body, $headers, $address);
204 * notify a user of subscription by another user
206 * This is just a wrapper around the profile-based version.
208 * @param User $listenee user who is being subscribed to
209 * @param User $listener user who is subscribing
211 * @see mail_subscribe_notify_profile()
215 function mail_subscribe_notify($listenee, $listener)
217 $other = $listener->getProfile();
218 mail_subscribe_notify_profile($listenee, $other);
222 * notify a user of subscription by a profile (remote or local)
224 * This function checks to see if the listenee has an email
225 * address and wants subscription notices.
227 * @param User $listenee user who's being subscribed to
228 * @param Profile $other profile of person who's listening
232 function mail_subscribe_notify_profile($listenee, $other)
234 if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
235 $listenee->email && $listenee->emailnotifysub) {
237 $profile = $listenee->getProfile();
239 $name = $profile->getBestName();
241 $long_name = ($other->fullname) ?
242 ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
244 $recipients = $listenee->email;
246 // use the recipient's localization
247 common_switch_locale($listenee->language);
249 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
250 $headers['From'] = mail_notify_from();
251 $headers['To'] = $name . ' <' . $listenee->email . '>';
252 // TRANS: Subject of new-subscriber notification e-mail.
253 // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
254 $headers['Subject'] = sprintf(_('%1$s is now following you on %2$s.'),
255 $other->getBestName(),
256 common_config('site', 'name'));
258 // TRANS: Main body of new-subscriber notification e-mail.
259 // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
260 $body = sprintf(_('%1$s is now following you on %2$s.'),
262 common_config('site', 'name')) .
263 mail_profile_block($other) .
266 // reset localization
267 common_switch_locale();
268 mail_send($recipients, $headers, $body);
272 function mail_subscribe_pending_notify_profile($listenee, $other)
274 if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
275 $listenee->email && $listenee->emailnotifysub) {
277 $profile = $listenee->getProfile();
279 $name = $profile->getBestName();
281 $long_name = ($other->fullname) ?
282 ($other->fullname . ' (' . $other->nickname . ')') : $other->nickname;
284 $recipients = $listenee->email;
286 // use the recipient's localization
287 common_switch_locale($listenee->language);
289 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
290 $headers['From'] = mail_notify_from();
291 $headers['To'] = $name . ' <' . $listenee->email . '>';
292 // TRANS: Subject of pending new-subscriber notification e-mail.
293 // TRANS: %1$s is the subscribing user's nickname, %2$s is the StatusNet sitename.
294 $headers['Subject'] = sprintf(_('%1$s would like to listen to '.
295 'your notices on %2$s.'),
296 $other->getBestName(),
297 common_config('site', 'name'));
299 // TRANS: Main body of pending new-subscriber notification e-mail.
300 // TRANS: %1$s is the subscriber's long name, %2$s is the StatusNet sitename.
301 $body = sprintf(_('%1$s would like to listen to your notices on %2$s. ' .
302 'You may approve or reject their subscription at %3$s'),
304 common_config('site', 'name'),
305 common_local_url('subqueue', array('nickname' => $listenee->nickname))) .
306 mail_profile_block($other) .
309 // reset localization
310 common_switch_locale();
311 mail_send($recipients, $headers, $body);
315 function mail_footer_block()
317 // TRANS: Common footer block for StatusNet notification emails.
318 // TRANS: %1$s is the StatusNet sitename,
319 // TRANS: %2$s is a link to the addressed user's e-mail settings.
320 return "\n\n" . sprintf(_('Faithfully yours,'.
323 "Change your email address or ".
324 "notification options at ".'%2$s'),
325 common_config('site', 'name'),
326 common_local_url('emailsettings')) . "\n";
330 * Format a block of profile info for a plaintext notification email.
332 * @param Profile $profile
335 function mail_profile_block($profile)
338 // TRANS: %1$s is the subscriber's profile URL, %2$s is the subscriber's location (or empty)
339 // TRANS: %3$s is the subscriber's homepage URL (or empty), %4%s is the subscriber's bio (or empty)
343 // TRANS: Profile info line in notification e-mail.
344 // TRANS: %s is a URL.
345 $out[] = sprintf(_("Profile: %s"), $profile->profileurl);
346 if ($profile->location) {
347 // TRANS: Profile info line in notification e-mail.
348 // TRANS: %s is a location.
349 $out[] = sprintf(_("Location: %s"), $profile->location);
351 if ($profile->homepage) {
352 // TRANS: Profile info line in notification e-mail.
353 // TRANS: %s is a homepage.
354 $out[] = sprintf(_("Homepage: %s"), $profile->homepage);
357 // TRANS: Profile info line in notification e-mail.
358 // TRANS: %s is biographical information.
359 $out[] = sprintf(_("Bio: %s"), $profile->bio);
362 $blocklink = common_local_url('block', array('profileid' => $profile->id));
363 // This'll let ModPlus add the remote profile info so it's possible
364 // to block remote users directly...
365 Event::handle('MailProfileInfoBlockLink', array($profile, &$blocklink));
367 // TRANS: This is a paragraph in a new-subscriber e-mail.
368 // TRANS: %s is a URL where the subscriber can be reported as abusive.
369 $out[] = sprintf(_('If you believe this account is being used abusively, ' .
370 'you can block them from your subscribers list and ' .
371 'report as spam to site administrators at %s.'),
375 return implode("\n", $out);
379 * notify a user of their new incoming email address
381 * User's email and incoming fields should already be updated.
383 * @param User $user user with the new address
387 function mail_new_incoming_notify($user)
389 $profile = $user->getProfile();
391 $name = $profile->getBestName();
393 $headers['From'] = $user->incomingemail;
394 $headers['To'] = $name . ' <' . $user->email . '>';
395 // TRANS: Subject of notification mail for new posting email address.
396 // TRANS: %s is the StatusNet sitename.
397 $headers['Subject'] = sprintf(_('New email address for posting to %s'),
398 common_config('site', 'name'));
400 // TRANS: Body of notification mail for new posting email address.
401 // TRANS: %1$s is the StatusNet sitename, %2$s is the e-mail address to send
402 // TRANS: to to post by e-mail, %3$s is a URL to more instructions.
403 $body = sprintf(_("You have a new posting address on %1\$s.\n\n".
404 "Send email to %2\$s to post new messages.\n\n".
405 "More email instructions at %3\$s."),
406 common_config('site', 'name'),
407 $user->incomingemail,
408 common_local_url('doc', array('title' => 'email'))) .
411 mail_send($user->email, $headers, $body);
415 * generate a new address for incoming messages
417 * @todo check the database for uniqueness
419 * @return string new email address for incoming messages
421 function mail_new_incoming_address()
423 $prefix = common_confirmation_code(64);
424 $suffix = mail_domain();
425 return $prefix . '@' . $suffix;
429 * broadcast a notice to all subscribers with SMS notification on
431 * This function sends SMS messages to all users who have sms addresses;
432 * have sms notification on; and have sms enabled for this particular
435 * @param Notice $notice The notice to broadcast
437 * @return success flag
439 function mail_broadcast_notice_sms($notice)
441 // Now, get users subscribed to this profile
445 $UT = common_config('db','type')=='pgsql'?'"user"':'user';
446 $replies = $notice->getReplies();
447 $user->query('SELECT nickname, smsemail, incomingemail ' .
448 "FROM $UT LEFT OUTER JOIN subscription " .
449 "ON $UT.id = subscription.subscriber " .
450 'AND subscription.subscribed = ' . $notice->profile_id . ' ' .
451 'AND subscription.subscribed != subscription.subscriber ' .
452 // Users (other than the sender) who `want SMS notices':
453 "WHERE $UT.id != " . $notice->profile_id . ' ' .
454 "AND $UT.smsemail IS NOT null " .
455 "AND $UT.smsnotify = 1 " .
456 // ... where either the user _is_ subscribed to the sender
457 // (any of the "subscription" fields IS NOT null)
458 // and wants to get SMS for all of this scribe's notices...
459 'AND (subscription.sms = 1 ' .
460 // ... or where the user was mentioned in
461 // or replied-to with the notice:
462 ($replies ? sprintf("OR $UT.id in (%s)",
463 implode(',', $replies))
467 while ($user->fetch()) {
469 'Sending notice ' . $notice->id . ' to ' . $user->smsemail,
471 $success = mail_send_sms_notice_address($notice,
473 $user->incomingemail,
476 // XXX: Not sure, but I think that's the right thing to do
477 common_log(LOG_WARNING,
478 'Sending notice ' . $notice->id . ' to ' .
479 $user->smsemail . ' FAILED, cancelling.',
492 * send a notice to a user via SMS
494 * A convenience wrapper around mail_send_sms_notice_address()
496 * @param Notice $notice notice to send
497 * @param User $user user to receive notice
499 * @see mail_send_sms_notice_address()
501 * @return boolean success flag
503 function mail_send_sms_notice($notice, $user)
505 return mail_send_sms_notice_address($notice,
507 $user->incomingemail,
512 * send a notice to an SMS email address from a given address
514 * We use the user's incoming email address as the "From" address to make
515 * replying to notices easier.
517 * @param Notice $notice notice to send
518 * @param string $smsemail email address to send to
519 * @param string $incomingemail email address to set as 'from'
520 * @param string $nickname nickname to add to beginning
522 * @return boolean success flag
524 function mail_send_sms_notice_address($notice, $smsemail, $incomingemail, $nickname)
526 $to = $nickname . ' <' . $smsemail . '>';
528 $other = $notice->getProfile();
530 common_log(LOG_INFO, 'Sending notice ' . $notice->id .
531 ' to ' . $smsemail, __FILE__);
535 $headers['From'] = ($incomingemail) ? $incomingemail : mail_notify_from();
536 $headers['To'] = $to;
537 // TRANS: Subject line for SMS-by-email notification messages.
538 // TRANS: %s is the posting user's nickname.
539 $headers['Subject'] = sprintf(_('%s status'),
540 $other->getBestName());
542 $body = $notice->content;
544 return mail_send($smsemail, $headers, $body);
548 * send a message to confirm a claim for an SMS number
550 * @param string $code confirmation code
551 * @param string $nickname nickname of user claiming number
552 * @param string $address email address to send the confirmation to
554 * @see common_confirmation_code()
558 function mail_confirm_sms($code, $nickname, $address)
560 $recipients = $address;
562 $headers['From'] = mail_notify_from();
563 $headers['To'] = $nickname . ' <' . $address . '>';
564 // TRANS: Subject line for SMS-by-email address confirmation message.
565 $headers['Subject'] = _('SMS confirmation');
567 // TRANS: Main body heading for SMS-by-email address confirmation message.
568 // TRANS: %s is the addressed user's nickname.
569 $body = sprintf(_('%s: confirm you own this phone number with this code:'), $nickname);
574 mail_send($recipients, $headers, $body);
578 * send a mail message to notify a user of a 'nudge'
580 * @param User $from user nudging
581 * @param User $to user being nudged
583 * @return boolean success flag
585 function mail_notify_nudge($from, $to)
587 common_switch_locale($to->language);
588 // TRANS: Subject for 'nudge' notification email.
589 // TRANS: %s is the nudging user.
590 $subject = sprintf(_('You have been nudged by %s'), $from->nickname);
592 $from_profile = $from->getProfile();
594 // TRANS: Body for 'nudge' notification email.
595 // TRANS: %1$s is the nuding user's long name, $2$s is the nudging user's nickname,
596 // TRANS: %3$s is a URL to post notices at.
597 $body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to ".
598 "these days and is inviting you to post some news.\n\n".
599 "So let's hear from you :)\n\n".
601 "Don't reply to this email; it won't get to them."),
602 $from_profile->getBestName(),
604 common_local_url('all', array('nickname' => $to->nickname))) .
606 common_switch_locale();
608 $headers = _mail_prepare_headers('nudge', $to->nickname, $from->nickname);
610 return mail_to_user($to, $subject, $body, $headers);
614 * send a message to notify a user of a direct message (DM)
616 * This function checks to see if the recipient wants notification
617 * of DMs and has a configured email address.
619 * @param Message $message message to notify about
620 * @param User $from user sending message; default to sender
621 * @param User $to user receiving message; default to recipient
623 * @return boolean success code
625 function mail_notify_message($message, $from=null, $to=null)
627 if (is_null($from)) {
628 $from = User::getKV('id', $message->from_profile);
632 $to = User::getKV('id', $message->to_profile);
635 if (is_null($to->email) || !$to->emailnotifymsg) {
639 common_switch_locale($to->language);
640 // TRANS: Subject for direct-message notification email.
641 // TRANS: %s is the sending user's nickname.
642 $subject = sprintf(_('New private message from %s'), $from->nickname);
644 $from_profile = $from->getProfile();
646 // TRANS: Body for direct-message notification email.
647 // TRANS: %1$s is the sending user's long name, %2$s is the sending user's nickname,
648 // TRANS: %3$s is the message content, %4$s a URL to the message,
649 $body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
650 "------------------------------------------------------\n".
652 "------------------------------------------------------\n\n".
653 "You can reply to their message here:\n\n".
655 "Don't reply to this email; it won't get to them."),
656 $from_profile->getBestName(),
659 common_local_url('newmessage', array('to' => $from->id))) .
662 $headers = _mail_prepare_headers('message', $to->nickname, $from->nickname);
664 common_switch_locale();
665 return mail_to_user($to, $subject, $body, $headers);
669 * Notify a user that they have received an "attn:" message AKA "@-reply"
671 * @param Profile $rcpt The Profile who recevied the notice, should be a local user
672 * @param Notice $notice The notice that was sent
676 function mail_notify_attn(Profile $rcpt, Notice $notice)
678 if (!$rcpt->isLocal()) {
682 $sender = $notice->getProfile();
683 if ($rcpt->sameAs($sender)) {
687 // See if the notice's author who mentions this user is sandboxed
688 if (!$sender->hasRight(Right::EMAILONREPLY)) {
692 // If the author has blocked the author, don't spam them with a notification.
693 if ($rcpt->hasBlocked($sender)) {
697 $user = $rcpt->getUser();
698 if (!$user->receivesEmailNotifications()) {
702 common_switch_locale($user->language);
704 if ($notice->hasConversation()) {
705 $conversationUrl = common_local_url('conversation',
706 array('id' => $notice->conversation)).'#notice-'.$notice->getID();
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'), $sender->getBestName(), $sender->getNickname());
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->getID())),//%3
737 $notice->getContent(),//%4
738 $conversationEmailText,//%5
739 common_local_url('newnotice',
740 array('replyto' => $sender->getNickname(), 'inreplyto' => $notice->getID())),//%6
741 common_local_url('replies',
742 array('nickname' => $rcpt->getNickname()))) . //%7
744 $headers = _mail_prepare_headers('mention', $rcpt->getNickname(), $sender->getNickname());
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);