summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mail.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/mail.php b/lib/mail.php
index 162669eaa..4788ccb91 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -231,3 +231,39 @@ function mail_confirm_sms($code, $nickname, $address) {
mail_send($recipients, $headers, $body);
}
+
+function mail_notify_message($message, $from=NULL, $to=NULL) {
+
+ if (is_null($from)) {
+ $from = User::staticGet($message->from_profile);
+ }
+
+ if (is_null($to)) {
+ $to = User::staticGet($message->to_profile);
+ }
+
+ if (!$to->email || !$to->emailnotifymsg) {
+ return true;
+ }
+
+ $subject = sprintf(_('New private message from %s'), $from->nickname);
+
+ $from_profile = $from->getProfile();
+
+ $body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
+ "------------------------------------------------------\n".
+ "%3\$s\n".
+ "------------------------------------------------------\n\n".
+ "You can reply to their message here:\n\n".
+ "%4\$s\n\n".
+ "Don't reply to this email; it won't get to them.\n\n".
+ "With kind regards,\n",
+ "%5\$s\n"),
+ $from_profile->getBestName(),
+ $from->nickname,
+ $message->content,
+ common_local_url('newmessage', array('to' => $from->id)),
+ common_config('site', 'name'));
+
+ return mail_to_user($to, $subject, $body);
+}