Changeset 1642


Ignore:
Timestamp:
Dec 8, 2006, 12:49:52 AM (17 years ago)
Author:
rub
Message:

Feature Issue ID 0000598:

Possibility to send HTML mail

Location:
trunk
Files:
6 added
2 edited

Legend:

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

    r1635 r1642  
    225225$conf['enabled_format_email'] = true;
    226226
     227// default_email_format:
     228//  Define the default email format use to send email
     229//  Value could be text/plain  or text/html
     230$conf['default_email_format'] = 'text/plain';
     231
    227232// check_upgrade_feed: check if there are database upgrade required. Set to
    228233// true, a message will strongly encourage you to upgrade your database if
  • trunk/include/functions_mail.inc.php

    r1541 r1642  
    5555    'mail_options' => $conf['mail_options'],
    5656    'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
     57    'default_email_format' => $conf['default_email_format']
    5758    );
    5859
     
    103104 * sends an email, using PhpWebGallery specific informations
    104105 */
    105 function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
     106function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $format_infos = 'text/plain', $email_format = null)
    106107{
    107   global $conf, $conf_mail, $lang_info;
     108  global $conf, $conf_mail, $lang_info, $user;
    108109
    109110  $cvt7b_subject = str_translate_to_ascii7bits($subject);
     
    112113  {
    113114    $conf_mail = get_mail_configuration();
     115  }
     116
     117  if (is_null($email_format))
     118  {
     119    $email_format = $conf_mail['default_email_format'];
     120  }
     121
     122  if (($format_infos == 'text/html') and ($email_format == 'text/plain'))
     123  {
     124    // Todo find function to convert html text to plain text
     125    return false;
    114126  }
    115127
     
    127139  $headers = 'From: '.$from."\n";
    128140  $headers.= 'Reply-To: '.$from."\n";
    129   $headers.= 'Content-Type: text/plain;format=flowed;charset="'.$lang_info['charset'].'";';
     141  $headers.= 'Content-Type: '.$email_format.';format=flowed;charset="'.$lang_info['charset'].'";';
    130142  $headers.= 'reply-type=original'."\n";
    131143
     
    134146    $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
    135147  }
    136  
    137   $content = $infos;
    138   $content.= $conf_mail['text_footer'];
     148
     149  list($tmpl, $thm) = explode('/', $conf['default_template']);
     150  $template_mail = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
     151
     152  $content = '';
     153
     154  if ($email_format == 'text/html')
     155  {
     156    $template_mail->set_filenames(array('mail_header'=>'mail/header.tpl'));
     157
     158    $template_mail->assign_vars(
     159      array(
     160        'BODY_ID' =>
     161          isset($page['body_id']) ?
     162            $page['body_id'] : '',
     163
     164        'CONTENT_ENCODING' => $lang_info['charset'],
     165        'LANG'=>$lang_info['code'],
     166        'DIR'=>$lang_info['direction']
     167
     168        ));
     169
     170    $content.= $template_mail->parse('mail_header', true);
     171  }
     172
     173  if (($format_infos == 'text/plain') and ($email_format == 'text/html'))
     174  {
     175    $content.= '<pre>'.htmlentities($infos).'</pre>';
     176  }
     177  else
     178  {
     179    $content.= $infos;
     180  }
     181
     182  if ($email_format == 'text/plain')
     183  {
     184    $content.= $conf_mail['text_footer'];
     185  }
     186  else
     187  {
     188    $template_mail->set_filenames(array('mail_footer'=>'footer.tpl'));
     189
     190    $template_mail->assign_vars(
     191      array(
     192        'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
     193
     194        'L_TITLE_MAIL' => urlencode(l10n('title_send_mail')),
     195        'MAIL' => get_webmaster_mail_address()
     196        ));
     197
     198    $content.= $template_mail->parse('mail_footer', true);
     199  }
    139200
    140201  if ($conf_mail['mail_options'])
Note: See TracChangeset for help on using the changeset viewer.