/** * send a message to confirm a claim for an SMS number * * @param string $code confirmation code * @param string $nickname nickname of user claiming number * @param string $address email address to send the confirmation to * * @see common_confirmation_code() * * @return void */ function mail_confirm_sms($code, $nickname, $address) { $recipients = $address; $headers['From'] = mail_notify_from(); $headers['To'] = $nickname . ' <' . $address . '>'; $headers['Subject'] = _('SMS confirmation'); // FIXME: I18N $body = "{$nickname}: confirm you own this phone number with this code:"; $body .= "\n\n"; $body .= $code; $body .= "\n\n"; mail_send($recipients, $headers, $body); }
/** * Send a real live email reminder * * @todo This would probably be better as two or more sep functions * * @param string $type type of reminder * @param mixed $object Confirm_address or Invitation object * @param string $subject subjct of the email reminder * @param string $title title of the email reminder * @return boolean true if the email subsystem doesn't explode */ static function sendReminderEmail($type, $object, $subject, $title = null) { $sitename = common_config('site', 'name'); $recipients = array($object->address); $inviter = null; $inviterurl = null; if ($type == UserInviteReminderHandler::INVITE_REMINDER) { $user = User::getKV($object->user_id); if (!empty($user)) { $profile = $user->getProfile(); $inviter = $profile->getBestName(); $inviterUrl = $profile->profileurl; } } $headers['From'] = mail_notify_from(); $headers['To'] = trim($object->address); // TRANS: Subject for confirmation e-mail. // TRANS: %s is the StatusNet sitename. $headers['Subject'] = $subject; $headers['Content-Type'] = 'text/html; charset=UTF-8'; $confirmUrl = common_local_url('register', array('code' => $object->code)); $template = DocFile::forTitle($title, DocFile::mailPaths()); $blankfillers = array('confirmurl' => $confirmUrl); if ($type == UserInviteReminderHandler::INVITE_REMINDER) { $blankfillers['inviter'] = $inviter; $blankfillers['inviterurl'] = $inviterUrl; // @todo private invitation message? } $body = $template->toHTML($blankfillers); return mail_send($recipients, $headers, $body); }
/** * send a message to confirm a claim for an SMS number * * @param string $code confirmation code * @param string $nickname nickname of user claiming number * @param string $address email address to send the confirmation to * * @see common_confirmation_code() * * @return void */ function mail_confirm_sms($code, $nickname, $address) { $recipients = $address; $headers['From'] = mail_notify_from(); $headers['To'] = $nickname . ' <' . $address . '>'; // TRANS: Subject line for SMS-by-email address confirmation message. $headers['Subject'] = _('SMS confirmation'); // TRANS: Main body heading for SMS-by-email address confirmation message. // TRANS: %s is the addressed user's nickname. $body = sprintf(_("%s: confirm you own this phone number with this code:"), $nickname); $body .= "\n\n"; $body .= $code; $body .= "\n\n"; mail_send($recipients, $headers, $body); }
/** * Send notification emails to group administrator. * * @param User_group $group * @param Profile $joiner */ function mail_notify_group_join_pending($group, $joiner) { $admin = $group->getAdmins(); while ($admin->fetch()) { // We need a local user for email notifications... $adminUser = User::staticGet('id', $admin->id); // @fixme check for email preference? if ($adminUser && $adminUser->email) { // use the recipient's localization common_switch_locale($adminUser->language); $headers = _mail_prepare_headers('join', $admin->nickname, $joiner->nickname); $headers['From'] = mail_notify_from(); $headers['To'] = $admin->getBestName() . ' <' . $adminUser->email . '>'; // TRANS: Subject of pending group join request notification e-mail. // TRANS: %1$s is the joining user's nickname, %2$s is the group name, and %3$s is the StatusNet sitename. $headers['Subject'] = sprintf(_('%1$s wants to join your group %2$s on %3$s.'), $joiner->getBestName(), $group->getBestName(), common_config('site', 'name')); // TRANS: Main body of pending group join request notification e-mail. // TRANS: %1$s is the subscriber's long name, %2$s is the group name, and %3$s is the StatusNet sitename, // TRANS: %4$s is the URL to the moderation queue page. $body = sprintf(_('%1$s would like to join your group %2$s on %3$s. ' . 'You may approve or reject their group membership at %4$s'), $joiner->getFancyName(), $group->getFancyName(), common_config('site', 'name'), common_local_url('groupqueue', array('nickname' => $group->nickname))) . mail_profile_block($joiner) . mail_footer_block(); // reset localization common_switch_locale(); mail_send($adminUser->email, $headers, $body); } } }
function sendConfirmEmail($confirm) { $sitename = common_config('site', 'name'); $recipients = array($confirm->address); $headers['From'] = mail_notify_from(); $headers['To'] = trim($confirm->address); // TRANS: Subject for confirmation e-mail. // TRANS: %s is the StatusNet sitename. $headers['Subject'] = sprintf(_m('Confirm your registration on %s'), $sitename); $confirmUrl = common_local_url('register', array('code' => $confirm->code)); // TRANS: Body for confirmation e-mail. // TRANS: %1$s is the StatusNet sitename, %2$s is the confirmation URL. $body = sprintf(_m('Someone (probably you) has requested an account on %1$s using this email address.' . "\n" . 'To confirm the address, click the following URL or copy it into the address bar of your browser.' . "\n" . '%2$s' . "\n" . 'If it was not you, you can safely ignore this message.'), $sitename, $confirmUrl); mail_send($recipients, $headers, $body); }
function sendInvitation($email, $user, $personal) { $profile = $user->getProfile(); $bestname = $profile->getBestName(); $sitename = common_config('site', 'name'); $invite = new Invitation(); $invite->address = $email; $invite->address_type = 'email'; $invite->code = common_confirmation_code(128); $invite->user_id = $user->id; $invite->created = common_sql_now(); if (!$invite->insert()) { common_log_db_error($invite, 'INSERT', __FILE__); return false; } $recipients = array($email); $headers['From'] = mail_notify_from(); $headers['To'] = trim($email); $headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename); $body = sprintf(_("%1\$s has invited you to join them on %2\$s (%3\$s).\n\n" . "%2\$s is a micro-blogging service that lets you keep up-to-date with people you know and people who interest you.\n\n" . "You can also share news about yourself, your thoughts, or your life online with people who know about you. " . "It's also great for meeting new people who share your interests.\n\n" . "%1\$s said:\n\n%4\$s\n\n" . "You can see %1\$s's profile page on %2\$s here:\n\n" . "%5\$s\n\n" . "If you'd like to try the service, click on the link below to accept the invitation.\n\n" . "%6\$s\n\n" . "If not, you can ignore this message. Thanks for your patience and your time.\n\n" . "Sincerely, %2\$s\n"), $bestname, $sitename, common_root_url(), $personal, common_local_url('showstream', array('nickname' => $user->nickname)), common_local_url('register', array('code' => $invite->code))); mail_send($recipients, $headers, $body); }
function sendInvitation($email, $user, $personal) { $profile = $user->getProfile(); $bestname = $profile->getBestName(); $sitename = common_config('site', 'name'); $invite = new Invitation(); $invite->address = $email; $invite->address_type = 'email'; $invite->code = common_confirmation_code(128); $invite->user_id = $user->id; $invite->created = common_sql_now(); if (!$invite->insert()) { common_log_db_error($invite, 'INSERT', __FILE__); return false; } $confirmUrl = common_local_url('register', array('code' => $invite->code)); $recipients = array($email); $headers['From'] = mail_notify_from(); $headers['To'] = trim($email); $headers['Content-Type'] = 'text/html; charset=UTF-8'; // TRANS: Subject for invitation email. Note that 'them' is correct as a gender-neutral // TRANS: singular 3rd-person pronoun in English. %1$s is the inviting user, $2$s is // TRANS: the StatusNet sitename. $headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename); $title = empty($personal) ? 'invite' : 'invitepersonal'; // @todo FIXME: i18n issue. $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths()); $body = $inviteTemplate->toHTML(array('inviter' => $bestname, 'inviterurl' => $profile->profileurl, 'confirmurl' => $confirmUrl, 'personal' => $personal)); common_debug('Confirm URL is ' . common_local_url('register', array('code' => $invite->code))); mail_send($recipients, $headers, $body); }
static function sendConfirmEmail($confirm, $title = null) { $sitename = common_config('site', 'name'); $recipients = array($confirm->address); $headers['From'] = mail_notify_from(); $headers['To'] = trim($confirm->address); // TRANS: Subject for confirmation e-mail. // TRANS: %s is the StatusNet sitename. $headers['Subject'] = sprintf(_m('Welcome to %s'), $sitename); $headers['Content-Type'] = 'text/html; charset=UTF-8'; $confirmUrl = common_local_url('register', array('code' => $confirm->code)); if (empty($title)) { $title = 'confirmemailreg'; } $confirmTemplate = DocFile::forTitle($title, DocFile::mailPaths()); $body = $confirmTemplate->toHTML(array('confirmurl' => $confirmUrl)); mail_send($recipients, $headers, $body); }