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 = $sitename;
27 $hostname = $a->get_hostname();
28 if(strpos($hostname,':'))
29 $hostname = substr($hostname,0,strpos($hostname,':'));
31 $sender_email = $a->config['sender_email'];
32 if (empty($sender_email)) {
33 $sender_email = t('noreply') . '@' . $hostname;
36 $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
38 $nickname = $user[0]["nickname"];
40 // with $params['show_in_notification_page'] == false, the notification isn't inserted into
41 // the database, and an email is sent if applicable.
42 // default, if not specified: true
43 $show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
45 $additional_mail_header = "";
46 $additional_mail_header .= "Precedence: list\n";
47 $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
48 $additional_mail_header .= "X-Friendica-Account: <".$nickname."@".$hostname.">\n";
49 $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
50 $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
51 $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
52 $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
55 if(array_key_exists('item',$params)) {
56 $title = $params['item']['title'];
57 $body = $params['item']['body'];
63 // e.g. "your post", "David's photo", etc.
64 $possess_desc = t('%s <!item_type!>');
66 if($params['type'] == NOTIFY_MAIL) {
68 $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
70 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
71 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
72 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
73 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
74 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
75 $itemlink = $siteurl . '/message/' . $params['item']['id'];
78 if($params['type'] == NOTIFY_COMMENT) {
79 // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
81 $parent_id = $params['parent'];
83 $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
85 intval($params['uid'])
87 if ($p AND count($p) AND ($p[0]["ignored"])) {
88 logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
92 // Check to see if there was already a tag notify or comment notify for this post.
93 // If so don't create a second notification
96 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
97 intval(NOTIFY_TAGSELF),
98 intval(NOTIFY_COMMENT),
100 dbesc($params['link']),
101 intval($params['uid'])
103 if($p and count($p)) {
109 // if it's a post figure out who's post it is.
113 if($params['otype'] === 'item' && $parent_id) {
114 $p = q("select * from item where id = %d and uid = %d limit 1",
116 intval($params['uid'])
120 $item_post_type = item_post_type($p[0]);
121 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
124 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
125 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
129 // "George Bull's post"
131 $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
132 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
134 $p[0]['author-name'],
138 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
139 $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
140 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
144 // Some mail softwares relies on subject field for threading.
145 // So, we cannot have different subjects for notifications of the same thread.
146 // Before this we have the name of the replier on the subject rendering
147 // differents subjects for messages on the same thread.
149 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
150 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
151 $epreamble = $dest_str;
153 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
154 $tsitelink = sprintf( $sitelink, $siteurl );
155 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
156 $itemlink = $params['link'];
159 if($params['type'] == NOTIFY_WALL) {
160 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
162 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
164 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
165 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
168 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
169 $tsitelink = sprintf( $sitelink, $siteurl );
170 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
171 $itemlink = $params['link'];
174 if($params['type'] == NOTIFY_TAGSELF) {
175 $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
176 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
177 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
178 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
181 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
182 $tsitelink = sprintf( $sitelink, $siteurl );
183 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
184 $itemlink = $params['link'];
187 if($params['type'] == NOTIFY_SHARE) {
188 $subject = sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
189 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
190 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
191 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
194 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
195 $tsitelink = sprintf( $sitelink, $siteurl );
196 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
197 $itemlink = $params['link'];
200 if($params['type'] == NOTIFY_POKE) {
202 $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
203 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
204 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') ,
205 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
208 $subject = str_replace('poked', t($params['activity']), $subject);
209 $preamble = str_replace('poked', t($params['activity']), $preamble);
210 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
212 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
213 $tsitelink = sprintf( $sitelink, $siteurl );
214 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
215 $itemlink = $params['link'];
218 if($params['type'] == NOTIFY_TAGSHARE) {
219 $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
220 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
221 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
222 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
225 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
226 $tsitelink = sprintf( $sitelink, $siteurl );
227 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
228 $itemlink = $params['link'];
231 if($params['type'] == NOTIFY_INTRO) {
232 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
233 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
234 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
236 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
237 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
239 $sitelink = t('Please visit %s to approve or reject the introduction.');
240 $tsitelink = sprintf( $sitelink, $siteurl );
241 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
242 $itemlink = $params['link'];
244 switch ($params['verb']) {
245 case ACTIVITY_FRIEND:
246 // someone started to share with user (mostly OStatus)
247 $subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
248 $preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
249 $epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
250 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
253 case ACTIVITY_FOLLOW:
254 // someone started to follow the user (mostly OStatus)
255 $subject = sprintf( t('[Friendica:Notify] You have a new follower'));
256 $preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
257 $epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
258 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
262 // ACTIVITY_REQ_FRIEND is default activity for notifications
269 if($params['type'] == NOTIFY_SUGGEST) {
270 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
271 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
272 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
274 '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
275 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
277 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
278 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
279 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
281 $sitelink = t('Please visit %s to approve or reject the suggestion.');
282 $tsitelink = sprintf( $sitelink, $siteurl );
283 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
284 $itemlink = $params['link'];
287 if($params['type'] == NOTIFY_CONFIRM) {
288 if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
289 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
290 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
291 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
293 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
294 $body = t('You are now mutual friends and may exchange status updates, photos, and email
295 without restriction.');
297 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
298 $tsitelink = sprintf( $sitelink, $siteurl );
299 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
300 $itemlink = $params['link'];
301 } else { // ACTIVITY_FOLLOW
302 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
303 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
304 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
306 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
307 $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']);
309 $body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
311 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
312 $tsitelink = sprintf( $sitelink, $siteurl );
313 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
314 $itemlink = $params['link'];
319 if($params['type'] == NOTIFY_SYSTEM) {
320 switch($params['event']) {
321 case "SYSTEM_REGISTER_REQUEST":
322 $subject = sprintf( t('[Friendica System:Notify] registration request'));
323 $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
324 $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
326 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
327 $body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
328 $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
330 $sitelink = t('Please visit %s to approve or reject the request.');
331 $tsitelink = sprintf( $sitelink, $params['link'] );
332 $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
333 $itemlink = $params['link'];
335 case "SYSTEM_DB_UPDATE_FAIL":
340 if ($params['type'] == "SYSTEM_EMAIL"){
341 // not part of the notifications.
342 // it just send a mail to the user.
343 // It will be used by the system to send emails to users (like
344 // password reset, invitations and so) using one look (but without
345 // add a notification to the user, with could be inexistent)
346 $subject = $params['subject'];
347 $preamble = $params['preamble'];
348 $body = $params['body'];
353 $show_in_notification_page = false;
356 $subject .= " (".$nickname."@".$hostname.")";
360 'subject' => $subject,
361 'preamble' => $preamble,
362 'epreamble' => $epreamble,
364 'sitelink' => $sitelink,
365 'tsitelink' => $tsitelink,
366 'hsitelink' => $hsitelink,
367 'itemlink' => $itemlink
370 call_hooks('enotify',$h);
372 $subject = $h['subject'];
373 $preamble = $h['preamble'];
374 $epreamble = $h['epreamble'];
376 $sitelink = $h['sitelink'];
377 $tsitelink = $h['tsitelink'];
378 $hsitelink = $h['hsitelink'];
379 $itemlink = $h['itemlink'];
383 if ($show_in_notification_page) {
384 logger("adding notification entry", LOGGER_DEBUG);
387 $hash = random_string();
388 $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
392 } while($dups == true);
396 $datarray['hash'] = $hash;
397 $datarray['name'] = $params['source_name'];
398 $datarray['url'] = $params['source_link'];
399 $datarray['photo'] = $params['source_photo'];
400 $datarray['date'] = datetime_convert();
401 $datarray['uid'] = $params['uid'];
402 $datarray['link'] = $itemlink;
403 $datarray['parent'] = $parent_id;
404 $datarray['type'] = $params['type'];
405 $datarray['verb'] = $params['verb'];
406 $datarray['otype'] = $params['otype'];
407 $datarray['abort'] = false;
409 call_hooks('enotify_store', $datarray);
411 if($datarray['abort']) {
416 // create notification entry in DB
418 $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
419 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
420 dbesc($datarray['hash']),
421 dbesc($datarray['name']),
422 dbesc($datarray['url']),
423 dbesc($datarray['photo']),
424 dbesc($datarray['date']),
425 intval($datarray['uid']),
426 dbesc($datarray['link']),
427 intval($datarray['parent']),
428 intval($datarray['type']),
429 dbesc($datarray['verb']),
430 dbesc($datarray['otype'])
433 $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
435 intval($params['uid'])
438 $notify_id = $r[0]['id'];
444 // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
445 // After we've stored everything, look again to see if there are any duplicates and if so remove them
448 $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
449 intval(NOTIFY_TAGSELF),
450 intval(NOTIFY_COMMENT),
451 dbesc($params['link']),
452 intval($params['uid'])
454 if($p && (count($p) > 1)) {
455 for ($d = 1; $d < count($p); $d ++) {
456 q("delete from notify where id = %d",
461 // only continue on if we stored the first one
463 if($notify_id != $p[0]['id']) {
470 $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
471 $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
472 $r = q("update notify set msg = '%s' where id = %d and uid = %d",
475 intval($params['uid'])
480 // send email notification if notification preferences permit
481 if((intval($params['notify_flags']) & intval($params['type']))
482 || $params['type'] == NOTIFY_SYSTEM
483 || $params['type'] == "SYSTEM_EMAIL") {
485 logger('sending notification email');
487 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
488 $id_for_parent = $params['parent']."@".$hostname;
490 // Is this the first email notification for this parent item and user?
492 $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
493 intval($params['parent']),
494 intval($params['uid']) );
496 // If so, create the record of it and use a message-id smtp header.
499 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
500 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
501 values(%d,%d,%d,%d)",
503 intval($params['parent']),
504 intval($params['uid']),
507 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
508 $log_msg = "include/enotify: No previous notification found for this parent:\n" .
509 " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n";
510 logger($log_msg, LOGGER_DEBUG);
512 // If not, just "follow" the thread.
513 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
514 logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
519 // textversion keeps linebreaks
520 $textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
521 $body))),ENT_QUOTES,'UTF-8')));
522 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
523 "<br />\n",$body))),ENT_QUOTES,'UTF-8');
527 $datarray['banner'] = $banner;
528 $datarray['product'] = $product;
529 $datarray['preamble'] = $preamble;
530 $datarray['sitename'] = $sitename;
531 $datarray['siteurl'] = $siteurl;
532 $datarray['type'] = $params['type'];
533 $datarray['parent'] = $params['parent'];
534 $datarray['source_name'] = $params['source_name'];
535 $datarray['source_link'] = $params['source_link'];
536 $datarray['source_photo'] = $params['source_photo'];
537 $datarray['uid'] = $params['uid'];
538 $datarray['username'] = $params['to_name'];
539 $datarray['hsitelink'] = $hsitelink;
540 $datarray['tsitelink'] = $tsitelink;
541 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
542 $datarray['titemlink'] = $itemlink;
543 $datarray['thanks'] = $thanks;
544 $datarray['site_admin'] = $site_admin;
545 $datarray['title'] = stripslashes($title);
546 $datarray['htmlversion'] = $htmlversion;
547 $datarray['textversion'] = $textversion;
548 $datarray['subject'] = $subject;
549 $datarray['headers'] = $additional_mail_header;
551 call_hooks('enotify_mail', $datarray);
553 // check whether sending post content in email notifications is allowed
554 // always true for "SYSTEM_EMAIL"
555 $content_allowed = ((!get_config('system','enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
557 // load the template for private message notifications
558 $tpl = get_markup_template('email_notify_html.tpl');
559 $email_html_body = replace_macros($tpl,array(
560 '$banner' => $datarray['banner'],
561 '$product' => $datarray['product'],
562 '$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
563 '$sitename' => $datarray['sitename'],
564 '$siteurl' => $datarray['siteurl'],
565 '$source_name' => $datarray['source_name'],
566 '$source_link' => $datarray['source_link'],
567 '$source_photo' => $datarray['source_photo'],
568 '$username' => $datarray['to_name'],
569 '$hsitelink' => $datarray['hsitelink'],
570 '$hitemlink' => $datarray['hitemlink'],
571 '$thanks' => $datarray['thanks'],
572 '$site_admin' => $datarray['site_admin'],
573 '$title' => $datarray['title'],
574 '$htmlversion' => $datarray['htmlversion'],
575 '$content_allowed' => $content_allowed,
578 // load the template for private message notifications
579 $tpl = get_markup_template('email_notify_text.tpl');
580 $email_text_body = replace_macros($tpl,array(
581 '$banner' => $datarray['banner'],
582 '$product' => $datarray['product'],
583 '$preamble' => $datarray['preamble'],
584 '$sitename' => $datarray['sitename'],
585 '$siteurl' => $datarray['siteurl'],
586 '$source_name' => $datarray['source_name'],
587 '$source_link' => $datarray['source_link'],
588 '$source_photo' => $datarray['source_photo'],
589 '$username' => $datarray['to_name'],
590 '$tsitelink' => $datarray['tsitelink'],
591 '$titemlink' => $datarray['titemlink'],
592 '$thanks' => $datarray['thanks'],
593 '$site_admin' => $datarray['site_admin'],
594 '$title' => $datarray['title'],
595 '$textversion' => $datarray['textversion'],
596 '$content_allowed' => $content_allowed,
599 // logger('text: ' . $email_text_body);
601 // use the Emailer class to send the message
603 return Emailer::send(array(
604 'uid' => $params['uid'],
605 'fromName' => $sender_name,
606 'fromEmail' => $sender_email,
607 'replyTo' => $sender_email,
608 'toEmail' => $params['to_email'],
609 'messageSubject' => $datarray['subject'],
610 'htmlVersion' => $email_html_body,
611 'textVersion' => $email_text_body,
612 'additionalMailHeader' => $datarray['headers'],