2 require_once('include/Emailer.php');
3 require_once('include/email.php');
4 require_once('include/bbcode.php');
5 require_once('include/html2bbcode.php');
7 function notification($params) {
9 #logger('notification()', LOGGER_DEBUG);
13 // from here on everything is in the recipients language
15 push_lang($params['language']);
18 $banner = t('Friendica Notification');
19 $product = FRIENDICA_PLATFORM;
20 $siteurl = $a->get_baseurl(true);
21 $thanks = t('Thank You,');
22 $sitename = $a->config['sitename'];
23 $site_admin = sprintf( t('%s Administrator'), $sitename);
26 $sender_name = $product;
27 $hostname = $a->get_hostname();
28 if(strpos($hostname,':'))
29 $hostname = substr($hostname,0,strpos($hostname,':'));
31 $sender_email = t('noreply') . '@' . $hostname;
33 $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
35 $nickname = $user[0]["nickname"];
37 // with $params['show_in_notification_page'] == false, the notification isn't inserted into
38 // the database, and an email is sent if applicable.
39 // default, if not specified: true
40 $show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
42 $additional_mail_header = "";
43 $additional_mail_header .= "Precedence: list\n";
44 $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
45 $additional_mail_header .= "X-Friendica-Account: <".$nickname."@".$hostname.">\n";
46 $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
47 $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
48 $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
49 $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
52 if(array_key_exists('item',$params)) {
53 $title = $params['item']['title'];
54 $body = $params['item']['body'];
60 // e.g. "your post", "David's photo", etc.
61 $possess_desc = t('%s <!item_type!>');
63 if($params['type'] == NOTIFY_MAIL) {
65 $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
67 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
68 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
69 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
70 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
71 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
72 $itemlink = $siteurl . '/message/' . $params['item']['id'];
75 if($params['type'] == NOTIFY_COMMENT) {
76 // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
78 $parent_id = $params['parent'];
80 $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
82 intval($params['uid'])
84 if ($p AND count($p) AND ($p[0]["ignored"])) {
85 logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
89 // Check to see if there was already a tag notify or comment notify for this post.
90 // If so don't create a second notification
93 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
94 intval(NOTIFY_TAGSELF),
95 intval(NOTIFY_COMMENT),
97 dbesc($params['link']),
98 intval($params['uid'])
100 if($p and count($p)) {
106 // if it's a post figure out who's post it is.
110 if($params['otype'] === 'item' && $parent_id) {
111 $p = q("select * from item where id = %d and uid = %d limit 1",
113 intval($params['uid'])
117 $item_post_type = item_post_type($p[0]);
118 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
121 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
122 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
126 // "George Bull's post"
128 $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
129 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
131 $p[0]['author-name'],
135 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
136 $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
137 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
141 // Some mail softwares relies on subject field for threading.
142 // So, we cannot have different subjects for notifications of the same thread.
143 // Before this we have the name of the replier on the subject rendering
144 // differents subjects for messages on the same thread.
146 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
147 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
148 $epreamble = $dest_str;
150 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
151 $tsitelink = sprintf( $sitelink, $siteurl );
152 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
153 $itemlink = $params['link'];
156 if($params['type'] == NOTIFY_WALL) {
157 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
159 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
161 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
162 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
165 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
166 $tsitelink = sprintf( $sitelink, $siteurl );
167 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
168 $itemlink = $params['link'];
171 if($params['type'] == NOTIFY_TAGSELF) {
172 $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
173 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
174 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
175 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
178 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
179 $tsitelink = sprintf( $sitelink, $siteurl );
180 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
181 $itemlink = $params['link'];
184 if($params['type'] == NOTIFY_SHARE) {
185 $subject = sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
186 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
187 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
188 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
191 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
192 $tsitelink = sprintf( $sitelink, $siteurl );
193 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
194 $itemlink = $params['link'];
197 if($params['type'] == NOTIFY_POKE) {
199 $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
200 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
201 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') ,
202 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
205 $subject = str_replace('poked', t($params['activity']), $subject);
206 $preamble = str_replace('poked', t($params['activity']), $preamble);
207 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
209 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
210 $tsitelink = sprintf( $sitelink, $siteurl );
211 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
212 $itemlink = $params['link'];
215 if($params['type'] == NOTIFY_TAGSHARE) {
216 $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
217 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
218 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
219 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
222 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
223 $tsitelink = sprintf( $sitelink, $siteurl );
224 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
225 $itemlink = $params['link'];
228 if($params['type'] == NOTIFY_INTRO) {
229 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
230 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
231 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
233 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
234 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
236 $sitelink = t('Please visit %s to approve or reject the introduction.');
237 $tsitelink = sprintf( $sitelink, $siteurl );
238 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
239 $itemlink = $params['link'];
241 switch ($params['verb']) {
242 case ACTIVITY_FRIEND:
243 // someone started to share with user (mostly OStatus)
244 $subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
245 $preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
246 $epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
247 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
250 case ACTIVITY_FOLLOW:
251 // someone started to follow the user (mostly OStatus)
252 $subject = sprintf( t('[Friendica:Notify] You have a new follower'));
253 $preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
254 $epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
255 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
259 // ACTIVITY_REQ_FRIEND is default activity for notifications
266 if($params['type'] == NOTIFY_SUGGEST) {
267 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
268 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
269 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
271 '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
272 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
274 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
275 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
276 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
278 $sitelink = t('Please visit %s to approve or reject the suggestion.');
279 $tsitelink = sprintf( $sitelink, $siteurl );
280 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
281 $itemlink = $params['link'];
284 if($params['type'] == NOTIFY_CONFIRM) {
285 if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
286 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
287 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
288 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
290 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
291 $body = t('You are now mutual friends and may exchange status updates, photos, and email
292 without restriction.');
294 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
295 $tsitelink = sprintf( $sitelink, $siteurl );
296 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
297 $itemlink = $params['link'];
298 } else { // ACTIVITY_FOLLOW
299 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
300 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
301 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
303 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
304 $body = sprintf(t('\'%1$s\' has chosen to accept you a "fan", which restricts some forms of communication - such as private messaging and some profile interactions. If this is a celebrity or community page, these settings were applied automatically.'), $params['source_name']);
306 $body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
308 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
309 $tsitelink = sprintf( $sitelink, $siteurl );
310 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
311 $itemlink = $params['link'];
316 if($params['type'] == NOTIFY_SYSTEM) {
317 switch($params['event']) {
318 case "SYSTEM_REGISTER_REQUEST":
319 $subject = sprintf( t('[Friendica System:Notify] registration request'));
320 $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
321 $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
323 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
324 $body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
325 $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
327 $sitelink = t('Please visit %s to approve or reject the request.');
328 $tsitelink = sprintf( $sitelink, $params['link'] );
329 $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
330 $itemlink = $params['link'];
332 case "SYSTEM_DB_UPDATE_FAIL":
337 if ($params['type'] == "SYSTEM_EMAIL"){
338 // not part of the notifications.
339 // it just send a mail to the user.
340 // It will be used by the system to send emails to users (like
341 // password reset, invitations and so) using one look (but without
342 // add a notification to the user, with could be inexistent)
343 $subject = $params['subject'];
344 $preamble = $params['preamble'];
345 $body = $params['body'];
350 $show_in_notification_page = false;
353 $subject .= " (".$nickname."@".$hostname.")";
357 'subject' => $subject,
358 'preamble' => $preamble,
359 'epreamble' => $epreamble,
361 'sitelink' => $sitelink,
362 'tsitelink' => $tsitelink,
363 'hsitelink' => $hsitelink,
364 'itemlink' => $itemlink
367 call_hooks('enotify',$h);
369 $subject = $h['subject'];
370 $preamble = $h['preamble'];
371 $epreamble = $h['epreamble'];
373 $sitelink = $h['sitelink'];
374 $tsitelink = $h['tsitelink'];
375 $hsitelink = $h['hsitelink'];
376 $itemlink = $h['itemlink'];
380 if ($show_in_notification_page) {
381 logger("adding notification entry", LOGGER_DEBUG);
384 $hash = random_string();
385 $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
389 } while($dups == true);
393 $datarray['hash'] = $hash;
394 $datarray['name'] = $params['source_name'];
395 $datarray['url'] = $params['source_link'];
396 $datarray['photo'] = $params['source_photo'];
397 $datarray['date'] = datetime_convert();
398 $datarray['uid'] = $params['uid'];
399 $datarray['link'] = $itemlink;
400 $datarray['parent'] = $parent_id;
401 $datarray['type'] = $params['type'];
402 $datarray['verb'] = $params['verb'];
403 $datarray['otype'] = $params['otype'];
404 $datarray['abort'] = false;
406 call_hooks('enotify_store', $datarray);
408 if($datarray['abort']) {
413 // create notification entry in DB
415 $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
416 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
417 dbesc($datarray['hash']),
418 dbesc($datarray['name']),
419 dbesc($datarray['url']),
420 dbesc($datarray['photo']),
421 dbesc($datarray['date']),
422 intval($datarray['uid']),
423 dbesc($datarray['link']),
424 intval($datarray['parent']),
425 intval($datarray['type']),
426 dbesc($datarray['verb']),
427 dbesc($datarray['otype'])
430 $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
432 intval($params['uid'])
435 $notify_id = $r[0]['id'];
441 // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
442 // After we've stored everything, look again to see if there are any duplicates and if so remove them
445 $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
446 intval(NOTIFY_TAGSELF),
447 intval(NOTIFY_COMMENT),
448 dbesc($params['link']),
449 intval($params['uid'])
451 if($p && (count($p) > 1)) {
452 for ($d = 1; $d < count($p); $d ++) {
453 q("delete from notify where id = %d",
458 // only continue on if we stored the first one
460 if($notify_id != $p[0]['id']) {
467 $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
468 $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
469 $r = q("update notify set msg = '%s' where id = %d and uid = %d",
472 intval($params['uid'])
477 // send email notification if notification preferences permit
478 if((intval($params['notify_flags']) & intval($params['type']))
479 || $params['type'] == NOTIFY_SYSTEM
480 || $params['type'] == "SYSTEM_EMAIL") {
482 logger('sending notification email');
484 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
485 $id_for_parent = $params['parent']."@".$hostname;
487 // Is this the first email notification for this parent item and user?
489 $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
490 intval($params['parent']),
491 intval($params['uid']) );
493 // If so, create the record of it and use a message-id smtp header.
496 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
497 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
498 values(%d,%d,%d,%d)",
500 intval($params['parent']),
501 intval($params['uid']),
504 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
505 $log_msg = "include/enotify: No previous notification found for this parent:\n" .
506 " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n";
507 logger($log_msg, LOGGER_DEBUG);
509 // If not, just "follow" the thread.
510 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
511 logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
516 // textversion keeps linebreaks
517 $textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
518 $body))),ENT_QUOTES,'UTF-8')));
519 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
520 "<br />\n",$body))),ENT_QUOTES,'UTF-8');
524 $datarray['banner'] = $banner;
525 $datarray['product'] = $product;
526 $datarray['preamble'] = $preamble;
527 $datarray['sitename'] = $sitename;
528 $datarray['siteurl'] = $siteurl;
529 $datarray['type'] = $params['type'];
530 $datarray['parent'] = $params['parent'];
531 $datarray['source_name'] = $params['source_name'];
532 $datarray['source_link'] = $params['source_link'];
533 $datarray['source_photo'] = $params['source_photo'];
534 $datarray['uid'] = $params['uid'];
535 $datarray['username'] = $params['to_name'];
536 $datarray['hsitelink'] = $hsitelink;
537 $datarray['tsitelink'] = $tsitelink;
538 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
539 $datarray['titemlink'] = $itemlink;
540 $datarray['thanks'] = $thanks;
541 $datarray['site_admin'] = $site_admin;
542 $datarray['title'] = stripslashes($title);
543 $datarray['htmlversion'] = $htmlversion;
544 $datarray['textversion'] = $textversion;
545 $datarray['subject'] = $subject;
546 $datarray['headers'] = $additional_mail_header;
548 call_hooks('enotify_mail', $datarray);
550 // check whether sending post content in email notifications is allowed
551 // always true for "SYSTEM_EMAIL"
552 $content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
554 // load the template for private message notifications
555 $tpl = get_markup_template('email_notify_html.tpl');
556 $email_html_body = replace_macros($tpl,array(
557 '$banner' => $datarray['banner'],
558 '$product' => $datarray['product'],
559 '$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
560 '$sitename' => $datarray['sitename'],
561 '$siteurl' => $datarray['siteurl'],
562 '$source_name' => $datarray['source_name'],
563 '$source_link' => $datarray['source_link'],
564 '$source_photo' => $datarray['source_photo'],
565 '$username' => $datarray['to_name'],
566 '$hsitelink' => $datarray['hsitelink'],
567 '$hitemlink' => $datarray['hitemlink'],
568 '$thanks' => $datarray['thanks'],
569 '$site_admin' => $datarray['site_admin'],
570 '$title' => $datarray['title'],
571 '$htmlversion' => $datarray['htmlversion'],
572 '$content_allowed' => $content_allowed,
575 // load the template for private message notifications
576 $tpl = get_markup_template('email_notify_text.tpl');
577 $email_text_body = replace_macros($tpl,array(
578 '$banner' => $datarray['banner'],
579 '$product' => $datarray['product'],
580 '$preamble' => $datarray['preamble'],
581 '$sitename' => $datarray['sitename'],
582 '$siteurl' => $datarray['siteurl'],
583 '$source_name' => $datarray['source_name'],
584 '$source_link' => $datarray['source_link'],
585 '$source_photo' => $datarray['source_photo'],
586 '$username' => $datarray['to_name'],
587 '$tsitelink' => $datarray['tsitelink'],
588 '$titemlink' => $datarray['titemlink'],
589 '$thanks' => $datarray['thanks'],
590 '$site_admin' => $datarray['site_admin'],
591 '$title' => $datarray['title'],
592 '$textversion' => $datarray['textversion'],
593 '$content_allowed' => $content_allowed,
596 // logger('text: ' . $email_text_body);
598 // use the Emailer class to send the message
600 return Emailer::send(array(
601 'uid' => $params['uid'],
602 'fromName' => $sender_name,
603 'fromEmail' => $sender_email,
604 'replyTo' => $sender_email,
605 'toEmail' => $params['to_email'],
606 'messageSubject' => $datarray['subject'],
607 'htmlVersion' => $email_html_body,
608 'textVersion' => $email_text_body,
609 'additionalMailHeader' => $datarray['headers'],