Changeset 25384


Ignore:
Timestamp:
Nov 7, 2013, 10:04:40 PM (10 years ago)
Author:
rvelices
Message:

mail func (use smarty3 syntax, better debugging with error reason)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_mail.inc.php

    r25372 r25384  
    679679      if ($content_type == 'text/html')
    680680      {
    681         if ($template->smarty->template_exists('global-mail-css.tpl'))
     681        if ($template->smarty->templateExists('global-mail-css.tpl'))
    682682        {
    683683          $template->set_filename('global-css', 'global-mail-css.tpl');
     
    685685        }
    686686
    687         if ($template->smarty->template_exists('mail-css-'. $args['theme'] .'.tpl'))
     687        if ($template->smarty->templateExists('mail-css-'. $args['theme'] .'.tpl'))
    688688        {
    689689          $template->set_filename('css', 'mail-css-'. $args['theme'] .'.tpl');
     
    738738        $template->set_template_dir($tpl['dirname'] .'/'. $content_type);
    739739      }
    740       if ($template->smarty->template_exists($tpl['filename'] .'.tpl'))
     740      if ($template->smarty->templateExists($tpl['filename'] .'.tpl'))
    741741      {
    742742        $template->set_filename($tpl['filename'], $tpl['filename'] .'.tpl');
     
    822822  {
    823823    $ret = $mail->send();
    824     if (!$ret and is_admin())
     824    if (!$ret and (!ini_get('display_errors') || is_admin()))
    825825    {
    826826      trigger_error('Mailer Error: ' . $mail->ErrorInfo, E_USER_WARNING);
     827    }
     828    if ($conf['debug_mail'])
     829    {
     830      pwg_send_mail_test($ret, $mail, $args);
    827831    }
    828832  }
     
    878882 * @return boolean $result
    879883 */
    880 function pwg_send_mail_test($result, $to, $args, $mail)
     884function pwg_send_mail_test($success, $mail, $args)
    881885{
    882886  global $conf, $user, $lang_info;
     
    885889  if (mkgetdir($dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR))
    886890  {
    887     $filename = $dir.'/mail.'.stripslashes($user['username']).'.'.$lang_info['code'].'.'.$args['theme'].'-'.date('YmdHis');
     891    $filename = $dir.'/mail.'.stripslashes($user['username']).'.'.$lang_info['code'].'-'.date('YmdHis').($success ? '' : '.ERROR');
    888892    if ($args['content_format'] == 'text/plain')
    889893    {
     
    896900   
    897901    $file = fopen($filename, 'w+');
    898     fwrite($file, implode(', ', $to) ."\n");
    899     fwrite($file, $mail->Subject ."\n");
    900     fwrite($file, $mail->createHeader() ."\n");
    901     fwrite($file, $mail->createBody());
     902    if (!$success)
     903    {
     904      fwrite($file, "ERROR: " . $mail->ErrorInfo . "\n\n");
     905    }
     906    fwrite($file, $mail->getSentMIMEMessage());
    902907    fclose($file);
    903908  }
    904  
    905   return $result;
    906 }
    907 
    908 if ($conf['debug_mail'])
    909 {
    910   add_event_handler('before_send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 4);
    911909}
    912910
Note: See TracChangeset for help on using the changeset viewer.