source: trunk/include/functions_mail.inc.php @ 2299

Last change on this file since 2299 was 2299, checked in by plg, 16 years ago

Bug fixed: as rvelices notified me by email, my header replacement script was
bugged (r2297 was repeating new and old header).

By the way, I've also removed the replacement keywords. We were using them
because it was a common usage with CVS but it is advised not to use them with
Subversion. Personnaly, it is a problem when I search differences between 2
Piwigo installations outside Subversion.

  • Property svn:keywords set to Author Date Id Revision
File size: 21.7 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24// +-----------------------------------------------------------------------+
25// |                               functions                               |
26// +-----------------------------------------------------------------------+
27
28
29/**
30 * Encodes a string using Q form if required (RFC2045)
31 * mail headers MUST contain only US-ASCII characters
32 */
33function encode_mime_header($str)
34{
35  $x = preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
36  if ($x==0)
37  {
38    return $str;
39  }
40  // Replace every high ascii, control =, ? and _ characters
41  $str = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
42                  "'='.sprintf('%02X', ord('\\1'))", $str);
43
44  // Replace every spaces to _ (more readable than =20)
45  $str = str_replace(" ", "_", $str);
46
47  global $lang_info;
48  return '=?'.get_pwg_charset().'?Q?'.$str.'?=';
49}
50
51/*
52 * Returns the name of the mail sender :
53 *
54 * @return string
55 */
56function get_mail_sender_name()
57{
58  global $conf;
59
60  return (empty($conf['mail_sender_name']) ? $conf['gallery_title'] : $conf['mail_sender_name']);
61}
62
63/*
64 * Returns an array of mail configuration parameters :
65 *
66 * - mail_options: see $conf['mail_options']
67 * - send_bcc_mail_webmaster: see $conf['send_bcc_mail_webmaster']
68 * - email_webmaster: mail corresponding to $conf['webmaster_id']
69 * - formated_email_webmaster: the name of webmaster is $conf['gallery_title']
70 * - text_footer: PhpWebGallery and version
71 *
72 * @return array
73 */
74function get_mail_configuration()
75{
76  global $conf;
77
78  $conf_mail = array(
79    'mail_options' => $conf['mail_options'],
80    'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
81    'default_email_format' => $conf['default_email_format'],
82    'use_smtp' => !empty($conf['smtp_host']),
83    'smtp_host' => $conf['smtp_host'],
84    'smtp_user' => $conf['smtp_user'],
85    'smtp_password' => $conf['smtp_password']
86    );
87
88  // we have webmaster id among user list, what's his email address ?
89  $conf_mail['email_webmaster'] = get_webmaster_mail_address();
90
91  // name of the webmaster is the title of the gallery
92  $conf_mail['formated_email_webmaster'] =
93    format_email(get_mail_sender_name(), $conf_mail['email_webmaster']);
94
95  $conf_mail['boundary_key'] = generate_key(32);
96
97  return $conf_mail;
98}
99
100/**
101 * Returns an email address with an associated real name
102 *
103 * @param string name
104 * @param string email
105 */
106function format_email($name, $email)
107{
108  // Spring cleaning
109  $cvt_email = trim(preg_replace('#[\n\r]+#s', '', $email));
110  $cvt_name = trim(preg_replace('#[\n\r]+#s', '', $name));
111
112  if ($cvt_name!="")
113  {
114    $cvt_name = encode_mime_header(
115              '"'
116              .addcslashes($cvt_name,'"')
117              .'"');
118    $cvt_name .= ' ';
119  }
120
121  if (strpos($cvt_email, '<') === false)
122  {
123    return $cvt_name.'<'.$cvt_email.'>';
124  }
125  else
126  {
127    return $cvt_name.$cvt_email;
128  }
129}
130
131/**
132 * Returns an email address list with minimal email string
133 *
134 * @param string with email list (email separated by comma)
135 */
136function get_strict_email_list($email_list)
137{
138  $result = array();
139  $list = explode(',', $email_list);
140  foreach ($list as $email)
141  {
142    if (strpos($email, '<') !== false)
143    {
144       $email = preg_replace('/.*<(.*)>.*/i', '$1', $email);
145    }
146    $result[] = trim($email);
147  }
148
149  return implode(',', $result);
150}
151
152/**
153 * Returns an completed array template/theme
154 * completed with get_default_template()
155 *
156 * @params:
157 *   - args: incompleted array of template/theme
158 *       o template: template to use [default get_default_template()]
159 *       o theme: template to use [default get_default_template()]
160 */
161function get_array_template_theme($args = array())
162{
163  global $conf;
164
165  $res = array();
166
167  if (empty($args['template']) or empty($args['theme']))
168  {
169    list($res['template'], $res['theme']) = explode('/', get_default_template());
170  }
171
172  if (!empty($args['template']))
173  {
174    $res['template'] = $args['template'];
175  }
176
177  if (!empty($args['theme']))
178  {
179    $res['theme'] = $args['theme'];
180  }
181
182  return $res;
183}
184
185/**
186 * Return an new mail template
187 *
188 * @params:
189 *   - email_format: mail format
190 *   - args: function params of mail function:
191 *       o template: template to use [default get_default_template()]
192 *       o theme: template to use [default get_default_template()]
193 */
194function & get_mail_template($email_format, $args = array())
195{
196  $args = get_array_template_theme($args);
197
198  $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']);
199  $mail_template->set_template_dir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format);
200  return $mail_template;
201}
202
203/**
204 * Return string email format (html or not)
205 *
206 * @param string format
207 */
208function get_str_email_format($is_html)
209{
210  return ($is_html ? 'text/html' : 'text/plain');
211}
212
213/*
214 * Switch language to param language
215 * All entries are push on language stack
216 *
217 * @param string language
218 */
219function switch_lang_to($language)
220{
221  global $switch_lang, $user, $lang, $lang_info;
222
223  if (count($switch_lang['stack']) == 0)
224  {
225    $prev_language = $user['language'];
226  }
227  else
228  {
229    $prev_language = end($switch_lang['stack']);
230  }
231
232  $switch_lang['stack'][] = $language;
233
234  if ($prev_language != $language)
235  {
236    if (!isset($switch_lang['language'][$prev_language]))
237    {
238      $switch_lang[$prev_language]['lang_info'] = $lang_info;
239      $switch_lang[$prev_language]['lang'] = $lang;
240    }
241
242    if (!isset($switch_lang['language'][$language]))
243    {
244      // Re-Init language arrays
245      $lang_info = array();
246      $lang  = array();
247
248      // language files
249      load_language('common.lang', '', $language);
250      // No test admin because script is checked admin (user selected no)
251      // Translations are in admin file too
252      load_language('admin.lang', '', $language);
253      trigger_action('loading_lang');
254      load_language('local.lang', '', $language);
255
256      $switch_lang[$language]['lang_info'] = $lang_info;
257      $switch_lang[$language]['lang'] = $lang;
258    }
259    else
260    {
261      $lang_info = $switch_lang[$language]['lang_info'];
262      $lang = $switch_lang[$language]['lang'];
263    }
264
265    $user['language'] = $language;
266  }
267}
268
269/*
270 * Switch back language pushed with switch_lang_to function
271 *
272 * @param: none
273 */
274function switch_lang_back()
275{
276  global $switch_lang, $user, $lang, $lang_info;
277
278  $last_language = array_pop($switch_lang['stack']);
279
280  if (count($switch_lang['stack']) > 0)
281  {
282    $language = end($switch_lang['stack']);
283  }
284  else
285  {
286    $language = $user['language'];
287  }
288
289  if ($last_language != $language)
290  {
291    if (!isset($switch_lang['language'][$language]))
292    {
293      $lang_info = $switch_lang[$language]['lang_info'];
294      $lang = $switch_lang[$language]['lang'];
295    }
296    $user['language'] = $language;
297  }
298}
299
300/**
301 * Returns email of all administrator
302 *
303 * @return string
304 */
305/*
306 * send en notification email to all administrators
307 * if a administrator is doing action,
308 * he's be removed to email list
309 *
310 * @param:
311 *   - keyargs_subject: mail subject on l10n_args format
312 *   - keyargs_content: mail content on l10n_args format
313 *
314 * @return boolean (Ok or not)
315 */
316function pwg_mail_notification_admins($keyargs_subject, $keyargs_content)
317{
318  // Check arguments
319  if
320    (
321      empty($keyargs_subject) or
322      empty($keyargs_content)
323    )
324  {
325    return false;
326  }
327
328  global $conf, $user;
329  $return = true;
330
331  $admins = array();
332
333  $query = '
334select
335  U.'.$conf['user_fields']['username'].' as username,
336  U.'.$conf['user_fields']['email'].' as mail_address
337from
338  '.USERS_TABLE.' as U,
339  '.USER_INFOS_TABLE.' as I
340where
341  I.user_id =  U.'.$conf['user_fields']['id'].' and
342  I.status in (\'webmaster\',  \'admin\') and
343  I.adviser = \'false\' and
344  '.$conf['user_fields']['email'].' is not null and
345  I.user_id <> '.$user['id'].'
346order by
347  username
348';
349
350  $datas = pwg_query($query);
351  if (!empty($datas))
352  {
353    while ($admin = mysql_fetch_array($datas))
354    {
355      if (!empty($admin['mail_address']))
356      {
357        array_push($admins, format_email($admin['username'], $admin['mail_address']));
358      }
359    }
360  }
361
362  if (count($admins) > 0)
363  {
364    $keyargs_content_admin_info = array
365    (
366      get_l10n_args('Connected user: %s', $user['username']),
367      get_l10n_args('IP: %s', $_SERVER['REMOTE_ADDR']),
368      get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT'])
369    );
370
371    switch_lang_to(get_default_language());
372
373    $return = pwg_mail
374    (
375      '',
376      array
377      (
378        'Bcc' => $admins,
379        'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
380        'content' =>
381           l10n_args($keyargs_content)."\n\n"
382          .l10n_args($keyargs_content_admin_info)."\n",
383        'content_format' => 'text/plain'
384      )
385    ) and $return;
386
387    switch_lang_back();
388  }
389
390  return $return;
391}
392
393/*
394 * send en email to user's group
395 *
396 * @param:
397 *   - group_id: mail are sent to group with this Id
398 *   - email_format: mail format
399 *   - keyargs_subject: mail subject on l10n_args format
400 *   - dirname: short name of directory including template
401 *   - tpl_shortname: short template name without extension
402 *   - assign_vars: array used to assign_vars to mail template
403 *   - language_selected: send mail only to user with this selected language
404 *
405 * @return boolean (Ok or not)
406 */
407function pwg_mail_group(
408  $group_id, $email_format, $keyargs_subject,
409  $dirname, $tpl_shortname,
410  $assign_vars = array(), $language_selected = '')
411{
412  // Check arguments
413  if
414    (
415      empty($group_id) or
416      empty($email_format) or
417      empty($keyargs_subject) or
418      empty($tpl_shortname)
419    )
420  {
421    return false;
422  }
423
424  global $conf;
425  $return = true;
426
427  $query = '
428SELECT
429  distinct language, template
430FROM
431  '.USER_GROUP_TABLE.' as ug
432  INNER JOIN '.USERS_TABLE.' as u  ON '.$conf['user_fields']['id'].' = ug.user_id
433  INNER JOIN '.USER_INFOS_TABLE.' as ui  ON ui.user_id = ug.user_id
434WHERE
435        '.$conf['user_fields']['email'].' IS NOT NULL
436    AND group_id = '.$group_id;
437
438  if (!empty($language_selected))
439  {
440    $query .= '
441    AND language = \''.$language_selected.'\'';
442  }
443
444    $query .= '
445;';
446
447  $result = pwg_query($query);
448
449  if (mysql_num_rows($result) > 0)
450  {
451    $list = array();
452    while ($row = mysql_fetch_array($result))
453    {
454      $row['template_theme'] = $row['template'];
455      list($row['template'], $row['theme']) = explode('/', $row['template_theme']);
456      $list[] = $row;
457    }
458
459    foreach ($list as $elem)
460    {
461      $query = '
462SELECT
463  u.'.$conf['user_fields']['username'].' as username,
464  u.'.$conf['user_fields']['email'].' as mail_address
465FROM
466  '.USER_GROUP_TABLE.' as ug
467  INNER JOIN '.USERS_TABLE.' as u  ON '.$conf['user_fields']['id'].' = ug.user_id
468  INNER JOIN '.USER_INFOS_TABLE.' as ui  ON ui.user_id = ug.user_id
469WHERE
470        '.$conf['user_fields']['email'].' IS NOT NULL
471    AND group_id = '.$group_id.'
472    AND language = \''.$elem['language'].'\'
473    AND template = \''.$elem['template_theme'].'\'
474;';
475
476      $result = pwg_query($query);
477
478      if (mysql_num_rows($result) > 0)
479      {
480        $Bcc = array();
481        while ($row = mysql_fetch_array($result))
482        {
483          if (!empty($row['mail_address']))
484          {
485            array_push($Bcc, format_email($row['username'], $row['mail_address']));
486          }
487        }
488
489        if (count($Bcc) > 0)
490        {
491          switch_lang_to($elem['language']);
492
493          $mail_template = get_mail_template($email_format, $elem);
494          $mail_template->set_filename($tpl_shortname,
495            (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
496
497          $mail_template->assign(
498            trigger_event('mail_group_assign_vars', $assign_vars));
499
500          $return = pwg_mail
501          (
502            '',
503            array
504            (
505              'Bcc' => $Bcc,
506              'subject' => l10n_args($keyargs_subject),
507              'email_format' => $email_format,
508              'content' => $mail_template->parse($tpl_shortname, true),
509              'content_format' => $email_format,
510              'template' => $elem['template'],
511              'theme' => $elem['theme']
512            )
513          ) and $return;
514
515          switch_lang_back();
516        }
517      }
518    }
519  }
520
521  return $return;
522}
523
524/*
525 * sends an email, using PhpWebGallery specific informations
526 *
527 * @param:
528 *   - to: receiver(s) of the mail (list separated by comma).
529 *   - args: function params of mail function:
530 *       o from: sender [default value webmaster email]
531 *       o Cc: array of carbon copy receivers of the mail. [default value empty]
532 *       o Bcc: array of blind carbon copy receivers of the mail. [default value empty]
533 *       o subject  [default value 'PhpWebGallery']
534 *       o content: content of mail    [default value '']
535 *       o content_format: format of mail content  [default value 'text/plain']
536 *       o email_format: global mail format  [default value $conf_mail['default_email_format']]
537 *       o template: template to use [default get_default_template()]
538 *       o theme: template to use [default get_default_template()]
539 *
540 * @return boolean (Ok or not)
541 */
542function pwg_mail($to, $args = array())
543{
544  global $conf, $conf_mail, $lang_info, $page;
545
546  if (empty($to) and empty($args['Cc']) and empty($args['Bcc']))
547  {
548    return true;
549  }
550
551  if (!isset($conf_mail))
552  {
553    $conf_mail = get_mail_configuration();
554  }
555
556  if (empty($args['email_format']))
557  {
558    $args['email_format'] = $conf_mail['default_email_format'];
559  }
560
561  // Compute root_path in order have complete path
562  if ($args['email_format'] == 'text/html')
563  {
564    set_make_full_url();
565  }
566
567  if (empty($args['from']))
568  {
569    $args['from'] = $conf_mail['formated_email_webmaster'];
570  }
571  else
572  {
573    $args['from'] = format_email('', $args['from']);
574  }
575
576  if (empty($args['subject']))
577  {
578    $args['subject'] = 'PhpWebGallery';
579  }
580  // Spring cleaning
581  $cvt_subject = trim(preg_replace('#[\n\r]+#s', '', $args['subject']));
582  // Ascii convertion
583  $cvt_subject = encode_mime_header($cvt_subject);
584
585  if (!isset($args['content']))
586  {
587    $args['content'] = '';
588  }
589
590  if (empty($args['content_format']))
591  {
592    $args['content_format'] = 'text/plain';
593  }
594
595  if ($conf_mail['send_bcc_mail_webmaster'])
596  {
597    $args['Bcc'][] = $conf_mail['formated_email_webmaster'];
598  }
599
600  if (($args['content_format'] == 'text/html') and ($args['email_format'] == 'text/plain'))
601  {
602    // Todo find function to convert html text to plain text
603    return false;
604  }
605
606  $args = array_merge($args, get_array_template_theme($args));
607
608  $headers = 'From: '.$args['from']."\n";
609  $headers.= 'Reply-To: '.$args['from']."\n";
610  if (empty($to))
611  {
612    $headers.= 'To: undisclosed-recipients: ;'."\n";
613  }
614  else
615  {
616    $headers.= 'To: '.$to."\n";
617  }
618
619  if (!empty($args['Cc']))
620  {
621    $headers.= 'Cc: '.implode(',', $args['Cc'])."\n";
622  }
623
624  if (!empty($args['Bcc']))
625  {
626    $headers.= 'Bcc: '.implode(',', $args['Bcc'])."\n";
627  }
628
629  $headers.= 'Content-Type: multipart/alternative;'."\n";
630  $headers.= '  boundary="---='.$conf_mail['boundary_key'].'";'."\n";
631  $headers.= '  reply-type=original'."\n";
632  $headers.= 'MIME-Version: 1.0'."\n";
633  $headers.= 'X-Mailer: Piwigo Mailer'."\n";
634
635  $content = '';
636
637  // key compose of indexes witch allow ti cache mail data
638  $cache_key = $args['email_format'].'-'.$lang_info['code'].'-'.$args['template'].'-'.$args['theme'];
639
640  if (!isset($conf_mail[$cache_key]))
641  {
642    if (!isset($mail_template))
643    {
644      $mail_template = get_mail_template($args['email_format']);
645    }
646
647    $mail_template->set_filename('mail_header', 'header.tpl');
648    $mail_template->set_filename('mail_footer', 'footer.tpl');
649
650    $mail_template->assign(
651      array(
652        //Header
653        'BOUNDARY_KEY' => $conf_mail['boundary_key'],
654        'CONTENT_TYPE' => $args['email_format'],
655        'CONTENT_ENCODING' => get_pwg_charset(),
656        'LANG' => $lang_info['code'],
657        'DIR' => $lang_info['direction'],
658
659        // Footer
660        'GALLERY_URL' =>
661          isset($page['gallery_url']) ?
662                $page['gallery_url'] : $conf['gallery_url'],
663        'GALLERY_TITLE' =>
664          isset($page['gallery_title']) ?
665                $page['gallery_title'] : $conf['gallery_title'],
666        'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
667        'PHPWG_URL' => PHPWG_URL,
668
669        'TITLE_MAIL' => urlencode(l10n('title_send_mail')),
670        'MAIL' => get_webmaster_mail_address()
671        ));
672
673    if ($args['email_format'] == 'text/html')
674    {
675      if (is_file($mail_template->get_template_dir().'/global-mail-css.tpl'))
676      {
677        $mail_template->set_filename('css', 'global-mail-css.tpl');
678        $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
679      }
680
681      $root_abs_path = dirname(dirname(__FILE__));
682
683      $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl';
684      if (is_file($file))
685      {
686        $mail_template->set_filename('css', $file);
687        $mail_template->assign_var_from_handle('MAIL_CSS', 'css');
688      }
689
690      $file = $root_abs_path.'/template-common/local-mail-css.tpl';
691      if (is_file($file))
692      {
693        $mail_template->set_filename('css', $file);
694        $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'css');
695      }
696    }
697
698    // what are displayed on the header of each mail ?
699    $conf_mail[$cache_key]['header'] =
700      $mail_template->parse('mail_header', true);
701
702    // what are displayed on the footer of each mail ?
703    $conf_mail[$cache_key]['footer'] =
704      $mail_template->parse('mail_footer', true);
705  }
706
707  // Header
708  $content.= $conf_mail[$cache_key]['header'];
709
710  // Content
711  if (($args['content_format'] == 'text/plain') and ($args['email_format'] == 'text/html'))
712  {
713    $content.= '<p>'.
714                nl2br(
715                  preg_replace("/(http:\/\/)([^\s,]*)/i",
716                               "<a href='$1$2'>$1$2</a>",
717                               htmlspecialchars($args['content']))).
718                '</p>';
719  }
720  else
721  {
722    $content.= $args['content'];
723  }
724
725  // Footer
726  $content.= $conf_mail[$cache_key]['footer'];
727
728  // Close boundary
729  $content.= "\n".'-----='.$conf_mail['boundary_key'].'--'."\n";
730
731   // Undo Compute root_path in order have complete path
732  if ($args['email_format'] == 'text/html')
733  {
734    unset_make_full_url();
735  }
736
737  return
738    trigger_event('send_mail',
739      false, /* Result */
740      trigger_event('send_mail_to', get_strict_email_list($to)),
741      trigger_event('send_mail_subject', $cvt_subject),
742      trigger_event('send_mail_content', $content),
743      trigger_event('send_mail_headers', $headers),
744      $args
745    );
746}
747
748/*
749 * pwg sendmail
750 *
751 * @param:
752 *   - result of other sendmail
753 *   - to: Receiver or receiver(s) of the mail.
754 *   - subject  [default value 'PhpWebGallery']
755 *   - content: content of mail
756 *   - headers: headers of mail
757 *
758 * @return boolean (Ok or not)
759 */
760function pwg_send_mail($result, $to, $subject, $content, $headers)
761{
762  if (!$result)
763  {
764    global $conf_mail;
765
766    if ($conf_mail['use_smtp'])
767    {
768      include_once( PHPWG_ROOT_PATH.'include/class_smtp_mail.inc.php' );
769      $smtp_mail = new smtp_mail(
770        $conf_mail['smtp_host'], $conf_mail['smtp_user'], $conf_mail['smtp_password'],
771        $conf_mail['email_webmaster']);
772      return $smtp_mail->mail($to, $subject, $content, $headers);
773    }
774    else
775    {
776      if ($conf_mail['mail_options'])
777      {
778        $options = '-f '.$conf_mail['email_webmaster'];
779        return mail($to, $subject, $content, $headers, $options);
780      }
781      else
782      {
783        return mail($to, $subject, $content, $headers);
784      }
785    }
786  }
787  else
788  {
789    return $result;
790  }
791}
792
793/*Testing block*/
794/*function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
795{
796    global $conf, $user, $lang_info;
797    $dir = $conf['local_data_dir'].'/tmp';
798    @mkdir( $dir );
799    $filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
800    if ($args['content_format'] == 'text/plain')
801    {
802      $filename .= '.txt';
803    }
804    else
805    {
806      $filename .= '.html';
807    }
808    $file = fopen($filename, 'w+');
809    fwrite($file, $to ."\n");
810    fwrite($file, $subject ."\n");
811    fwrite($file, $headers);
812    fwrite($file, $content);
813    fclose($file);
814    return $result;
815}
816add_event_handler('send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 6);*/
817
818
819add_event_handler('send_mail', 'pwg_send_mail', EVENT_HANDLER_PRIORITY_NEUTRAL, 5);
820trigger_action('functions_mail_included');
821
822?>
Note: See TracBrowser for help on using the repository browser.