From 130ba2888643992943780962dd4efcca3c595735 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 17 Sep 2008 13:47:41 -0400 Subject: newmessage and showmessage darcs-hash:20080917174741-5ed1f-c090055487bab0df52d25ad6550d3850ef5f7661.gz --- lib/mail.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'lib') 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); +} -- cgit v1.2.3-54-g00ecf