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);
25 $sender_name = $product;
26 $hostname = $a->get_hostname();
27 if(strpos($hostname,':'))
28 $hostname = substr($hostname,0,strpos($hostname,':'));
30 $sender_email = t('noreply') . '@' . $hostname;
32 // with $params['show_in_notification_page'] == false, the notification isn't inserted into
33 // the database, and an email is sent if applicable.
34 // default, if not specified: true
35 $show_in_notification_page = ((x($params,'show_in_notification_page')) ? $params['show_in_notification_page']:True);
37 $additional_mail_header = "";
38 $additional_mail_header .= "Precedence: list\n";
39 $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
40 $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
41 $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
42 $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
43 $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
46 if(array_key_exists('item',$params)) {
47 $title = $params['item']['title'];
48 $body = $params['item']['body'];
54 // e.g. "your post", "David's photo", etc.
55 $possess_desc = t('%s <!item_type!>');
57 if($params['type'] == NOTIFY_MAIL) {
59 $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
61 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
62 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
63 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
64 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
65 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
66 $itemlink = $siteurl . '/message/' . $params['item']['id'];
69 if($params['type'] == NOTIFY_COMMENT) {
70 // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
72 $parent_id = $params['parent'];
74 $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
76 intval($params['uid'])
78 if ($p AND count($p) AND ($p[0]["ignored"])) {
79 logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
83 // Check to see if there was already a tag notify or comment notify for this post.
84 // If so don't create a second notification
87 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
88 intval(NOTIFY_TAGSELF),
89 intval(NOTIFY_COMMENT),
91 dbesc($params['link']),
92 intval($params['uid'])
94 if($p and count($p)) {
100 // if it's a post figure out who's post it is.
104 if($params['otype'] === 'item' && $parent_id) {
105 $p = q("select * from item where id = %d and uid = %d limit 1",
107 intval($params['uid'])
111 $item_post_type = item_post_type($p[0]);
112 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
115 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
116 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
120 // "George Bull's post"
122 $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
123 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
125 $p[0]['author-name'],
129 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
130 $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
131 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
135 // Some mail softwares relies on subject field for threading.
136 // So, we cannot have different subjects for notifications of the same thread.
137 // Before this we have the name of the replier on the subject rendering
138 // differents subjects for messages on the same thread.
140 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
141 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']);
142 $epreamble = $dest_str;
144 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
145 $tsitelink = sprintf( $sitelink, $siteurl );
146 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
147 $itemlink = $params['link'];
150 if($params['type'] == NOTIFY_WALL) {
151 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
153 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
155 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
156 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
159 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
160 $tsitelink = sprintf( $sitelink, $siteurl );
161 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
162 $itemlink = $params['link'];
165 if($params['type'] == NOTIFY_TAGSELF) {
166 $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
167 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
168 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
169 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
172 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
173 $tsitelink = sprintf( $sitelink, $siteurl );
174 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
175 $itemlink = $params['link'];
178 if($params['type'] == NOTIFY_SHARE) {
179 $subject = sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
180 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
181 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
182 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
185 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
186 $tsitelink = sprintf( $sitelink, $siteurl );
187 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
188 $itemlink = $params['link'];
191 if($params['type'] == NOTIFY_POKE) {
193 $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
194 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
195 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') ,
196 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
199 $subject = str_replace('poked', t($params['activity']), $subject);
200 $preamble = str_replace('poked', t($params['activity']), $preamble);
201 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
203 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
204 $tsitelink = sprintf( $sitelink, $siteurl );
205 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
206 $itemlink = $params['link'];
209 if($params['type'] == NOTIFY_TAGSHARE) {
210 $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
211 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
212 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
213 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
216 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
217 $tsitelink = sprintf( $sitelink, $siteurl );
218 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
219 $itemlink = $params['link'];
222 if($params['type'] == NOTIFY_INTRO) {
223 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
224 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
225 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
227 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
228 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
230 $sitelink = t('Please visit %s to approve or reject the introduction.');
231 $tsitelink = sprintf( $sitelink, $siteurl );
232 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
233 $itemlink = $params['link'];
235 switch ($params['verb']) {
236 case ACTIVITY_FRIEND:
237 // someone started to share with user (mostly OStatus)
238 $subject = sprintf( t('[Friendica:Notify] A new person is sharing with you'));
239 $preamble = sprintf( t('%1$s is sharing with you at %2$s'), $params['source_name'], $sitename);
240 $epreamble = sprintf( t('%1$s is sharing with you at %2$s'),
241 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
244 case ACTIVITY_FOLLOW:
245 // someone started to follow the user (mostly OStatus)
246 $subject = sprintf( t('[Friendica:Notify] You have a new follower'));
247 $preamble = sprintf( t('You have a new follower at %2$s : %1$s'), $params['source_name'], $sitename);
248 $epreamble = sprintf( t('You have a new follower at %2$s : %1$s'),
249 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
253 // ACTIVITY_REQ_FRIEND is default activity for notifications
260 if($params['type'] == NOTIFY_SUGGEST) {
261 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
262 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
263 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
265 '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
266 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
268 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
269 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
270 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
272 $sitelink = t('Please visit %s to approve or reject the suggestion.');
273 $tsitelink = sprintf( $sitelink, $siteurl );
274 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
275 $itemlink = $params['link'];
278 if($params['type'] == NOTIFY_CONFIRM) {
279 if ($params['verb'] == ACTIVITY_FRIEND ){ // mutual connection
280 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
281 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
282 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
284 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
285 $body = t('You are now mutual friends and may exchange status updates, photos, and email
286 without restriction.');
288 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
289 $tsitelink = sprintf( $sitelink, $siteurl );
290 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
291 $itemlink = $params['link'];
292 } else { // ACTIVITY_FOLLOW
293 $subject = sprintf( t('[Friendica:Notify] Connection accepted'));
294 $preamble = sprintf( t('\'%1$s\' has acepted your connection request at %2$s'), $params['source_name'], $sitename);
295 $epreamble = sprintf( t('%2$s has accepted your [url=%1$s]connection request[/url].'),
297 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
298 $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']);
300 $body .= sprintf(t('\'%1$s\' may choose to extend this into a two-way or more permissive relationship in the future. '), $params['source_name']);
302 $sitelink = t('Please visit %s if you wish to make any changes to this relationship.');
303 $tsitelink = sprintf( $sitelink, $siteurl );
304 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
305 $itemlink = $params['link'];
310 if($params['type'] == NOTIFY_SYSTEM) {
311 switch($params['event']) {
312 case "SYSTEM_REGISTER_REQUEST":
313 $subject = sprintf( t('[Friendica System:Notify] registration request'));
314 $preamble = sprintf( t('You\'ve received a registration request from \'%1$s\' at %2$s'), $params['source_name'], $sitename);
315 $epreamble = sprintf( t('You\'ve received a [url=%1$s]registration request[/url] from %2$s.'),
317 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]');
318 $body = sprintf( t('Full Name: %1$s\nSite Location: %2$s\nLogin Name: %3$s (%4$s)'),
319 $params['source_name'], $siteurl, $params['source_mail'], $params['source_nick']);
321 $sitelink = t('Please visit %s to approve or reject the request.');
322 $tsitelink = sprintf( $sitelink, $params['link'] );
323 $hsitelink = sprintf( $sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
324 $itemlink = $params['link'];
326 case "SYSTEM_DB_UPDATE_FAIL":
331 if ($params['type'] == "SYSTEM_EMAIL"){
332 // not part of the notifications.
333 // it just send a mail to the user.
334 // It will be used by the system to send emails to users (like
335 // password reset, invitations and so) using one look (but without
336 // add a notification to the user, with could be inexistent)
337 $subject = $params['subject'];
338 $preamble = $params['preamble'];
339 $body = $params['body'];
344 $show_in_notification_page = false;
351 'subject' => $subject,
352 'preamble' => $preamble,
353 'epreamble' => $epreamble,
355 'sitelink' => $sitelink,
356 'tsitelink' => $tsitelink,
357 'hsitelink' => $hsitelink,
358 'itemlink' => $itemlink
361 call_hooks('enotify',$h);
363 $subject = $h['subject'];
364 $preamble = $h['preamble'];
365 $epreamble = $h['epreamble'];
367 $sitelink = $h['sitelink'];
368 $tsitelink = $h['tsitelink'];
369 $hsitelink = $h['hsitelink'];
370 $itemlink = $h['itemlink'];
374 if ($show_in_notification_page) {
375 logger("adding notification entry", LOGGER_DEBUG);
378 $hash = random_string();
379 $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
383 } while($dups == true);
387 $datarray['hash'] = $hash;
388 $datarray['name'] = $params['source_name'];
389 $datarray['url'] = $params['source_link'];
390 $datarray['photo'] = $params['source_photo'];
391 $datarray['date'] = datetime_convert();
392 $datarray['uid'] = $params['uid'];
393 $datarray['link'] = $itemlink;
394 $datarray['parent'] = $parent_id;
395 $datarray['type'] = $params['type'];
396 $datarray['verb'] = $params['verb'];
397 $datarray['otype'] = $params['otype'];
398 $datarray['abort'] = false;
400 call_hooks('enotify_store', $datarray);
402 if($datarray['abort']) {
407 // create notification entry in DB
409 $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
410 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
411 dbesc($datarray['hash']),
412 dbesc($datarray['name']),
413 dbesc($datarray['url']),
414 dbesc($datarray['photo']),
415 dbesc($datarray['date']),
416 intval($datarray['uid']),
417 dbesc($datarray['link']),
418 intval($datarray['parent']),
419 intval($datarray['type']),
420 dbesc($datarray['verb']),
421 dbesc($datarray['otype'])
424 $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
426 intval($params['uid'])
429 $notify_id = $r[0]['id'];
435 // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
436 // After we've stored everything, look again to see if there are any duplicates and if so remove them
439 $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
440 intval(NOTIFY_TAGSELF),
441 intval(NOTIFY_COMMENT),
442 dbesc($params['link']),
443 intval($params['uid'])
445 if($p && (count($p) > 1)) {
446 for ($d = 1; $d < count($p); $d ++) {
447 q("delete from notify where id = %d",
452 // only continue on if we stored the first one
454 if($notify_id != $p[0]['id']) {
461 $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
462 $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
463 $r = q("update notify set msg = '%s' where id = %d and uid = %d",
466 intval($params['uid'])
471 // send email notification if notification preferences permit
472 if((intval($params['notify_flags']) & intval($params['type']))
473 || $params['type'] == NOTIFY_SYSTEM
474 || $params['type'] == "SYSTEM_EMAIL") {
476 logger('sending notification email');
478 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
479 $id_for_parent = $params['parent']."@".$hostname;
481 // Is this the first email notification for this parent item and user?
483 $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
484 intval($params['parent']),
485 intval($params['uid']) );
487 // If so, create the record of it and use a message-id smtp header.
490 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
491 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
492 values(%d,%d,%d,%d)",
494 intval($params['parent']),
495 intval($params['uid']),
498 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
499 $log_msg = "include/enotify: No previous notification found for this parent:\n" .
500 " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n";
501 logger($log_msg, LOGGER_DEBUG);
503 // If not, just "follow" the thread.
504 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
505 logger("There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
510 // textversion keeps linebreaks
511 $textversion = strip_tags(str_replace("<br>","\n",html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
512 $body))),ENT_QUOTES,'UTF-8')));
513 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
514 "<br />\n",$body))),ENT_QUOTES,'UTF-8');
518 $datarray['banner'] = $banner;
519 $datarray['product'] = $product;
520 $datarray['preamble'] = $preamble;
521 $datarray['sitename'] = $sitename;
522 $datarray['siteurl'] = $siteurl;
523 $datarray['type'] = $params['type'];
524 $datarray['parent'] = $params['parent'];
525 $datarray['source_name'] = $params['source_name'];
526 $datarray['source_link'] = $params['source_link'];
527 $datarray['source_photo'] = $params['source_photo'];
528 $datarray['uid'] = $params['uid'];
529 $datarray['username'] = $params['to_name'];
530 $datarray['hsitelink'] = $hsitelink;
531 $datarray['tsitelink'] = $tsitelink;
532 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
533 $datarray['titemlink'] = $itemlink;
534 $datarray['thanks'] = $thanks;
535 $datarray['site_admin'] = $site_admin;
536 $datarray['title'] = stripslashes($title);
537 $datarray['htmlversion'] = $htmlversion;
538 $datarray['textversion'] = $textversion;
539 $datarray['subject'] = $subject;
540 $datarray['headers'] = $additional_mail_header;
542 call_hooks('enotify_mail', $datarray);
544 // check whether sending post content in email notifications is allowed
545 $content_allowed = !get_config('system','enotify_no_content');
547 // load the template for private message notifications
548 $tpl = get_markup_template('email_notify_html.tpl');
549 $email_html_body = replace_macros($tpl,array(
550 '$banner' => $datarray['banner'],
551 '$product' => $datarray['product'],
552 '$preamble' => str_replace("\n","<br>\n",$datarray['preamble']),
553 '$sitename' => $datarray['sitename'],
554 '$siteurl' => $datarray['siteurl'],
555 '$source_name' => $datarray['source_name'],
556 '$source_link' => $datarray['source_link'],
557 '$source_photo' => $datarray['source_photo'],
558 '$username' => $datarray['to_name'],
559 '$hsitelink' => $datarray['hsitelink'],
560 '$hitemlink' => $datarray['hitemlink'],
561 '$thanks' => $datarray['thanks'],
562 '$site_admin' => $datarray['site_admin'],
563 '$title' => $datarray['title'],
564 '$htmlversion' => $datarray['htmlversion'],
565 '$content_allowed' => $content_allowed,
568 // load the template for private message notifications
569 $tpl = get_markup_template('email_notify_text.tpl');
570 $email_text_body = replace_macros($tpl,array(
571 '$banner' => $datarray['banner'],
572 '$product' => $datarray['product'],
573 '$preamble' => $datarray['preamble'],
574 '$sitename' => $datarray['sitename'],
575 '$siteurl' => $datarray['siteurl'],
576 '$source_name' => $datarray['source_name'],
577 '$source_link' => $datarray['source_link'],
578 '$source_photo' => $datarray['source_photo'],
579 '$username' => $datarray['to_name'],
580 '$tsitelink' => $datarray['tsitelink'],
581 '$titemlink' => $datarray['titemlink'],
582 '$thanks' => $datarray['thanks'],
583 '$site_admin' => $datarray['site_admin'],
584 '$title' => $datarray['title'],
585 '$textversion' => $datarray['textversion'],
586 '$content_allowed' => $content_allowed,
589 // logger('text: ' . $email_text_body);
591 // use the Emailer class to send the message
593 return Emailer::send(array(
594 'fromName' => $sender_name,
595 'fromEmail' => $sender_email,
596 'replyTo' => $sender_email,
597 'toEmail' => $params['to_email'],
598 'messageSubject' => $datarray['subject'],
599 'htmlVersion' => $email_html_body,
600 'textVersion' => $email_text_body,
601 'additionalMailHeader' => $datarray['headers'],