]> git.mxchange.org Git - friendica.git/blob - include/enotify.php
BBCode: Add a linefeed between a picture and the following text. This is important...
[friendica.git] / include / enotify.php
1 <?php
2
3 require_once('include/email.php');
4
5 function notification($params) {
6
7         logger('notification: entry', LOGGER_DEBUG);
8
9         $a = get_app();
10
11         // from here on everything is in the recipients language
12
13         push_lang($params['language']);
14
15
16         $banner = t('Friendica Notification');
17         $product = FRIENDICA_PLATFORM;
18         $siteurl = $a->get_baseurl(true);
19         $thanks = t('Thank You,');
20         $sitename = $a->config['sitename'];
21         $site_admin = sprintf( t('%s Administrator'), $sitename);
22
23         $sender_name = $product;
24         $hostname = $a->get_hostname();
25         if(strpos($hostname,':'))
26                 $hostname = substr($hostname,0,strpos($hostname,':'));
27
28         $sender_email = t('noreply') . '@' . $hostname;
29         $additional_mail_header = "";
30
31         $additional_mail_header .= "Precedence: list\n";
32         $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n";
33         $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n";
34         $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n";
35         $additional_mail_header .= "List-ID: <notification.".$hostname.">\n";
36         $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n";
37
38         if(array_key_exists('item',$params)) {
39                 $title = $params['item']['title'];
40                 $body = $params['item']['body'];
41         }
42         else {
43                 $title = $body = '';
44         }
45
46         // e.g. "your post", "David's photo", etc.
47         $possess_desc = t('%s <!item_type!>');
48
49         if($params['type'] == NOTIFY_MAIL) {
50
51                 $subject =      sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename);
52
53                 $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
54                 $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
55                 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
56                 $tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
57                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
58                 $itemlink = $siteurl . '/message/' . $params['item']['id'];
59         }
60
61         if($params['type'] == NOTIFY_COMMENT) {
62 //              logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
63
64                 $parent_id = $params['parent'];
65
66                 // Check to see if there was already a tag notify or comment notify for this post.
67                 // If so don't create a second notification
68
69                 $p = null;
70                 $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1",
71                         intval(NOTIFY_TAGSELF),
72                         intval(NOTIFY_COMMENT),
73                         intval(NOTIFY_SHARE),
74                         dbesc($params['link']),
75                         intval($params['uid'])
76                 );
77                 if($p and count($p)) {
78                         pop_lang();
79                         return;
80                 }
81
82
83                 // if it's a post figure out who's post it is.
84
85                 $p = null;
86
87                 if($params['otype'] === 'item' && $parent_id) {
88                         $p = q("select * from item where id = %d and uid = %d limit 1",
89                                 intval($parent_id),
90                                 intval($params['uid'])
91                         );
92                 }
93
94                 $item_post_type = item_post_type($p[0]);
95                 //$possess_desc = str_replace('<!item_type!>',$possess_desc);
96
97                 // "a post"
98                 $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'),
99                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
100                                                                 $itemlink,
101                                                                 $item_post_type);
102
103                 // "George Bull's post"
104                 if($p)
105                         $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'),
106                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
107                                                 $itemlink,
108                                                 $p[0]['author-name'],
109                                                 $item_post_type);
110
111                 // "your post"
112                 if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall'])
113                         $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'),
114                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
115                                                                 $itemlink,
116                                                                 $item_post_type);
117
118                 // Some mail softwares relies on subject field for threading.
119                 // So, we cannot have different subjects for notifications of the same thread.
120                 // Before this we have the name of the replier on the subject rendering 
121                 // differents subjects for messages on the same thread.
122
123                 $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
124                 $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); 
125                 $epreamble = $dest_str;
126
127                 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
128                 $tsitelink = sprintf( $sitelink, $siteurl );
129                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
130                 $itemlink =  $params['link'];
131         }
132
133         if($params['type'] == NOTIFY_WALL) {
134                 $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']);
135
136                 $preamble = sprintf( t('%1$s posted to your profile wall at %2$s') , $params['source_name'], $sitename);
137
138                 $epreamble = sprintf( t('%1$s posted to [url=%2$s]your wall[/url]') ,
139                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
140                                                                 $params['link']);
141
142                 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
143                 $tsitelink = sprintf( $sitelink, $siteurl );
144                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
145                 $itemlink =  $params['link'];
146         }
147
148         if($params['type'] == NOTIFY_TAGSELF) {
149                 $subject =      sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']);
150                 $preamble = sprintf( t('%1$s tagged you at %2$s') , $params['source_name'], $sitename);
151                 $epreamble = sprintf( t('%1$s [url=%2$s]tagged you[/url].') ,
152                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
153                                                                 $params['link']);
154
155                 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
156                 $tsitelink = sprintf( $sitelink, $siteurl );
157                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
158                 $itemlink =  $params['link'];
159         }
160
161         if($params['type'] == NOTIFY_SHARE) {
162                 $subject =      sprintf( t('[Friendica:Notify] %s shared a new post') , $params['source_name']);
163                 $preamble = sprintf( t('%1$s shared a new post at %2$s') , $params['source_name'], $sitename);
164                 $epreamble = sprintf( t('%1$s [url=%2$s]shared a post[/url].') ,
165                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
166                                                                 $params['link']);
167
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'];
172         }
173
174         if($params['type'] == NOTIFY_POKE) {
175
176                 $subject =      sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']);
177                 $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename);
178                 $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') , 
179                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
180                                                                 $params['link']); 
181
182                 $subject = str_replace('poked', t($params['activity']), $subject);
183                 $preamble = str_replace('poked', t($params['activity']), $preamble);
184                 $epreamble = str_replace('poked', t($params['activity']), $epreamble);
185
186                 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
187                 $tsitelink = sprintf( $sitelink, $siteurl );
188                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
189                 $itemlink =  $params['link'];
190         }
191
192         if($params['type'] == NOTIFY_TAGSHARE) {
193                 $subject =      sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']);
194                 $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename);
195                 $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') ,
196                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]',
197                                                                 $itemlink); 
198
199                 $sitelink = t('Please visit %s to view and/or reply to the conversation.');
200                 $tsitelink = sprintf( $sitelink, $siteurl );
201                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
202                 $itemlink =  $params['link'];
203         }
204
205         if($params['type'] == NOTIFY_INTRO) {
206                 $subject = sprintf( t('[Friendica:Notify] Introduction received'));
207                 $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename); 
208                 $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'),
209                                                                 $itemlink,
210                                                                 '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); 
211                 $body = sprintf( t('You may visit their profile at %s'),$params['source_link']);
212
213                 $sitelink = t('Please visit %s to approve or reject the introduction.');
214                 $tsitelink = sprintf( $sitelink, $siteurl );
215                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
216                 $itemlink =  $params['link'];
217         }
218
219         if($params['type'] == NOTIFY_SUGGEST) {
220                 $subject = sprintf( t('[Friendica:Notify] Friend suggestion received'));
221                 $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename); 
222                 $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'),
223                                                                         $itemlink,
224                                                                         '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]',
225                                                                         '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); 
226
227                 $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
228                 $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
229                 $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']);
230
231                 $sitelink = t('Please visit %s to approve or reject the suggestion.');
232                 $tsitelink = sprintf( $sitelink, $siteurl );
233                 $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
234                 $itemlink =  $params['link'];
235         }
236
237         if($params['type'] == NOTIFY_CONFIRM) {
238         }
239
240         if($params['type'] == NOTIFY_SYSTEM) {
241
242         }
243
244         $h = array(
245                 'params'    => $params, 
246                 'subject'   => $subject,
247                 'preamble'  => $preamble, 
248                 'epreamble' => $epreamble, 
249                 'body'      => $body, 
250                 'sitelink'  => $sitelink,
251                 'tsitelink' => $tsitelink,
252                 'hsitelink' => $hsitelink,
253                 'itemlink'  => $itemlink
254         );
255
256         call_hooks('enotify',$h);
257
258         $subject   = $h['subject'];
259         $preamble  = $h['preamble'];
260         $epreamble = $h['epreamble'];
261         $body      = $h['body'];
262         $sitelink  = $h['sitelink'];
263         $tsitelink = $h['tsitelink'];
264         $hsitelink = $h['hsitelink'];
265         $itemlink  = $h['itemlink'];
266
267
268         require_once('include/html2bbcode.php');
269
270         do {
271                 $dups = false;
272                 $hash = random_string();
273         $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
274                         dbesc($hash));
275                 if(count($r))
276                         $dups = true;
277         } while($dups == true);
278
279
280         $datarray = array();
281         $datarray['hash']  = $hash;
282         $datarray['name']  = $params['source_name'];
283         $datarray['url']   = $params['source_link'];
284         $datarray['photo'] = $params['source_photo'];
285         $datarray['date']  = datetime_convert();
286         $datarray['uid']   = $params['uid'];
287         $datarray['link']  = $itemlink;
288         $datarray['parent'] = $parent_id;
289         $datarray['type']  = $params['type'];
290         $datarray['verb']  = $params['verb'];
291         $datarray['otype'] = $params['otype'];
292         $datarray['abort'] = false;
293  
294         call_hooks('enotify_store', $datarray);
295
296         if($datarray['abort']) {
297                 pop_lang();
298                 return;
299         }
300
301         // create notification entry in DB
302
303         $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)
304                 values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')",
305                 dbesc($datarray['hash']),
306                 dbesc($datarray['name']),
307                 dbesc($datarray['url']),
308                 dbesc($datarray['photo']),
309                 dbesc($datarray['date']),
310                 intval($datarray['uid']),
311                 dbesc($datarray['link']),
312                 intval($datarray['parent']),
313                 intval($datarray['type']),
314                 dbesc($datarray['verb']),
315                 dbesc($datarray['otype'])
316         );
317
318         $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
319                 dbesc($hash),
320                 intval($params['uid'])
321         );
322         if($r)
323                 $notify_id = $r[0]['id'];
324         else {
325                 pop_lang();
326                 return;
327         }
328
329         // we seem to have a lot of duplicate comment notifications due to race conditions, mostly from forums
330         // After we've stored everything, look again to see if there are any duplicates and if so remove them
331
332         $p = null;
333         $p = q("select id from notify where ( type = %d or type = %d ) and link = '%s' and uid = %d order by id",
334                 intval(NOTIFY_TAGSELF),
335                 intval(NOTIFY_COMMENT),
336                 dbesc($params['link']),
337                 intval($params['uid'])
338         );
339         if($p && (count($p) > 1)) {
340                 for ($d = 1; $d < count($p); $d ++) {
341                         q("delete from notify where id = %d",
342                                 intval($p[$d]['id'])
343                         );
344                 }
345
346                 // only continue on if we stored the first one
347
348                 if($notify_id != $p[0]['id']) {
349                         pop_lang();
350                         return;
351                 }
352         }
353
354
355
356
357
358
359
360
361         $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
362         $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
363         $r = q("update notify set msg = '%s' where id = %d and uid = %d",
364                 dbesc($msg),
365                 intval($notify_id),
366                 intval($params['uid'])
367         );
368
369
370         // send email notification if notification preferences permit
371
372         require_once('include/bbcode.php');
373         if((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) {
374
375                 logger('notification: sending notification email');
376
377                 if (isset($params['parent']) AND (intval($params['parent']) != 0)) {
378                         $id_for_parent = $params['parent']."@".$hostname;
379
380                         // Is this the first email notification for this parent item and user?
381
382                         $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1",
383                                 intval($params['parent']),
384                                 intval($params['uid']) );
385
386                         // If so, create the record of it and use a message-id smtp header.
387
388                         if(!$r) {
389                                 logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG);
390                                 $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)
391                                         values(%d,%d,%d,%d)",
392                                         intval($notify_id),
393                                         intval($params['parent']),
394                                         intval($params['uid']), 
395                                         0 );
396
397                                 $additional_mail_header .= "Message-ID: <${id_for_parent}>\n";
398                                 $log_msg = "include/enotify: No previous notification found for this parent:\n" . 
399                                                 "  parent: ${params['parent']}\n" . "  uid   : ${params['uid']}\n";
400                                 logger($log_msg, LOGGER_DEBUG);
401                         } else {
402                                 // If not, just "follow" the thread.
403                                 $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n";
404                                 logger("include/enotify: There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
405                         }
406                 }
407
408
409                 $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
410                         $body))),ENT_QUOTES,'UTF-8'));
411                 $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
412                         "<br />\n",$body))),ENT_QUOTES,'UTF-8');
413
414                 $datarray = array();
415                 $datarray['banner'] = $banner;
416                 $datarray['product'] = $product;
417                 $datarray['preamble'] = $preamble;
418                 $datarray['sitename'] = $sitename;
419                 $datarray['siteurl'] = $siteurl;
420                 $datarray['type'] = $params['type'];
421                 $datarray['parent'] = $params['parent'];
422                 $datarray['source_name'] = $params['source_name'];
423                 $datarray['source_link'] = $params['source_link'];
424                 $datarray['source_photo'] = $params['source_photo'];
425                 $datarray['uid'] = $params['uid'];
426                 $datarray['username'] = $params['to_name'];
427                 $datarray['hsitelink'] = $hsitelink;
428                 $datarray['tsitelink'] = $tsitelink;
429                 $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
430                 $datarray['titemlink'] = $itemlink;
431                 $datarray['thanks'] = $thanks;
432                 $datarray['site_admin'] = $site_admin;
433                 $datarray['title'] = stripslashes($title);
434                 $datarray['htmlversion'] = $htmlversion;
435                 $datarray['textversion'] = $textversion;
436                 $datarray['subject'] = $subject;
437                 $datarray['headers'] = $additional_mail_header;
438
439                 call_hooks('enotify_mail', $datarray);
440
441                 // check whether sending post content in email notifications is allowed
442                 $content_allowed = !get_config('system','enotify_no_content');
443
444                 // load the template for private message notifications
445                 $tpl = get_markup_template('email_notify_html.tpl');
446                 $email_html_body = replace_macros($tpl,array(
447                         '$banner'       => $datarray['banner'],
448                         '$product'      => $datarray['product'],
449                         '$preamble'     => $datarray['preamble'],
450                         '$sitename'     => $datarray['sitename'],
451                         '$siteurl'      => $datarray['siteurl'],
452                         '$source_name'  => $datarray['source_name'],
453                         '$source_link'  => $datarray['source_link'],
454                         '$source_photo' => $datarray['source_photo'],
455                         '$username'     => $datarray['to_name'],
456                         '$hsitelink'    => $datarray['hsitelink'],
457                         '$hitemlink'    => $datarray['hitemlink'],
458                         '$thanks'       => $datarray['thanks'],
459                         '$site_admin'   => $datarray['site_admin'],
460                         '$title'                => $datarray['title'],
461                         '$htmlversion'  => $datarray['htmlversion'],
462                         '$content_allowed'      => $content_allowed,
463                 ));
464                 
465                 // load the template for private message notifications
466                 $tpl = get_markup_template('email_notify_text.tpl');
467                 $email_text_body = replace_macros($tpl,array(
468                         '$banner'       => $datarray['banner'],
469                         '$product'      => $datarray['product'],
470                         '$preamble'     => $datarray['preamble'],
471                         '$sitename'     => $datarray['sitename'],
472                         '$siteurl'      => $datarray['siteurl'],
473                         '$source_name'  => $datarray['source_name'],
474                         '$source_link'  => $datarray['source_link'],
475                         '$source_photo' => $datarray['source_photo'],
476                         '$username'     => $datarray['to_name'],
477                         '$tsitelink'    => $datarray['tsitelink'],
478                         '$titemlink'    => $datarray['titemlink'],
479                         '$thanks'       => $datarray['thanks'],
480                         '$site_admin'   => $datarray['site_admin'],
481                         '$title'                => $datarray['title'],
482                         '$textversion'  => $datarray['textversion'],    
483                         '$content_allowed'      => $content_allowed,
484                 ));
485
486 //              logger('text: ' . $email_text_body);
487
488                 // use the EmailNotification library to send the message
489
490                 enotify::send(array(
491                         'fromName' => $sender_name,
492                         'fromEmail' => $sender_email,
493                         'replyTo' => $sender_email,
494                         'toEmail' => $params['to_email'],
495                         'messageSubject' => $datarray['subject'],
496                         'htmlVersion' => $email_html_body,
497                         'textVersion' => $email_text_body,
498                         'additionalMailHeader' => $datarray['headers'],
499                 ));
500         }
501
502         pop_lang();
503
504 }
505
506 require_once('include/email.php');
507
508 class enotify {
509         /**
510          * Send a multipart/alternative message with Text and HTML versions
511          *
512          * @param fromName                      name of the sender
513          * @param fromEmail                     email fo the sender
514          * @param replyTo                       replyTo address to direct responses
515          * @param toEmail                       destination email address
516          * @param messageSubject        subject of the message
517          * @param htmlVersion           html version of the message
518          * @param textVersion           text only version of the message
519          * @param additionalMailHeader  additions to the smtp mail header
520          */
521         static public function send($params) {
522
523                 $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); 
524                 $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
525                 
526                 // generate a mime boundary
527                 $mimeBoundary   =rand(0,9)."-"
528                                 .rand(10000000000,9999999999)."-"
529                                 .rand(10000000000,9999999999)."=:"
530                                 .rand(10000,99999);
531
532                 // generate a multipart/alternative message header
533                 $messageHeader =
534                         $params['additionalMailHeader'] .
535                         "From: $fromName <{$params['fromEmail']}>\n" . 
536                         "Reply-To: $fromName <{$params['replyTo']}>\n" .
537                         "MIME-Version: 1.0\n" .
538                         "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
539
540                 // assemble the final multipart message body with the text and html types included
541                 $textBody       =       chunk_split(base64_encode($params['textVersion']));
542                 $htmlBody       =       chunk_split(base64_encode($params['htmlVersion']));
543                 $multipartMessageBody =
544                         "--" . $mimeBoundary . "\n" .                                   // plain text section
545                         "Content-Type: text/plain; charset=UTF-8\n" .
546                         "Content-Transfer-Encoding: base64\n\n" .
547                         $textBody . "\n" .
548                         "--" . $mimeBoundary . "\n" .                                   // text/html section
549                         "Content-Type: text/html; charset=UTF-8\n" .
550                         "Content-Transfer-Encoding: base64\n\n" .
551                         $htmlBody . "\n" .
552                         "--" . $mimeBoundary . "--\n";                                  // message ending
553
554                 // send the message
555                 $res = mail(
556                         $params['toEmail'],                                                                             // send to address
557                         $messageSubject,                                                                // subject
558                         $multipartMessageBody,                                                  // message body
559                         $messageHeader                                                                  // message headers
560                 );
561                 logger("notification: enotify::send header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
562                 logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
563         }
564 }
565 ?>