$conf['mail_options'], 'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'], 'default_email_format' => $conf['default_email_format'] ); // we have webmaster id among user list, what's his email address ? $conf_mail['email_webmaster'] = get_webmaster_mail_address(); // name of the webmaster is the title of the gallery $conf_mail['formated_email_webmaster'] = format_email($conf['gallery_title'], $conf_mail['email_webmaster']); // what to display at the bottom of each mail ? $conf_mail['text_footer'] = "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : ''); return $conf_mail; } /** * Returns an email address with an associated real name * * @param string name * @param string email */ function format_email($name, $email) { global $conf; if ($conf['enabled_format_email']) { $cvt7b_name = str_translate_to_ascii7bits($name); if (strpos($email, '<') === false) { return $cvt7b_name.' <'.$email.'>'; } else { return $cvt7b_name.$email; } } else { return $email; } } /** * Returns an new mail template * * @param none */ function get_mail_template() { global $conf; // for mail, default template are used list($tmpl, $thm) = explode('/', $conf['default_template']); $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm); return $mail_template; } /** * sends an email, using PhpWebGallery specific informations */ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $format_infos = 'text/plain', $email_format = null) { global $conf, $conf_mail, $lang_info, $user, $page; $cvt7b_subject = str_translate_to_ascii7bits($subject); if (!isset($conf_mail)) { $conf_mail = get_mail_configuration(); } if (is_null($email_format)) { $email_format = $conf_mail['default_email_format']; } if (($format_infos == 'text/html') and ($email_format == 'text/plain')) { // Todo find function to convert html text to plain text return false; } // Compute root_path in order have complete path if ($email_format == 'text/html') { set_make_full_url(); } $to = format_email('', $to); if ($from == '') { $from = $conf_mail['formated_email_webmaster']; } else { $from = format_email('', $from); } $headers = 'From: '.$from."\n"; $headers.= 'Reply-To: '.$from."\n"; $headers.= 'Content-Type: '.$email_format.';format=flowed;charset="'.$lang_info['charset'].'";'; $headers.= 'reply-type=original'."\n"; if ($conf_mail['send_bcc_mail_webmaster']) { $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n"; } $content = ''; if (!isset($conf_mail[$email_format][$lang_info['charset']]['header'])) { if ($email_format == 'text/html') { $mail_template = get_mail_template(); $mail_template->set_filenames(array('mail_header'=>'mail/header.tpl')); $mail_template->assign_vars( array( 'BODY_ID' => isset($page['body_id']) ? $page['body_id'] : '', 'CONTENT_ENCODING' => $lang_info['charset'], 'LANG' => $lang_info['code'], 'DIR' => $lang_info['direction'] )); $conf_mail[$email_format][$lang_info['charset']]['header'] = $mail_template->parse('mail_header', true); } else { $conf_mail[$email_format][$lang_info['charset']]['header'] = ''; } } $content.= $conf_mail[$email_format][$lang_info['charset']]['header']; if (($format_infos == 'text/plain') and ($email_format == 'text/html')) { $content.= '
'.htmlentities($infos).'
'; } else { $content.= $infos; } if (!isset($conf_mail[$email_format][$lang_info['charset']]['footer'])) { if ($email_format == 'text/html') { $mail_template->set_filenames(array('mail_footer'=>'mail/footer.tpl')); $mail_template->assign_vars( array( 'GALLERY_URL' => isset($page['gallery_url']) ? $page['gallery_url'] : $conf['gallery_url'], 'GALLERY_TITLE' => isset($page['gallery_title']) ? $page['gallery_title'] : $conf['gallery_title'], 'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => PHPWG_URL, 'TITLE_MAIL' => urlencode(l10n('title_send_mail')), 'MAIL' => get_webmaster_mail_address() )); $conf_mail[$email_format][$lang_info['charset']]['footer'] = $mail_template->parse('mail_footer', true); } else { $conf_mail[$email_format][$lang_info['charset']]['footer'] = $conf_mail['text_footer']; } } $content.= $conf_mail[$email_format][$lang_info['charset']]['footer']; // Undo Compute root_path in order have complete path if ($email_format == 'text/html') { unset_make_full_url(); } if ($conf_mail['mail_options']) { $options = '-f '.$conf_mail['email_webmaster']; return mail($to, $cvt7b_subject, $content, $headers, $options); } else { return mail($to, $cvt7b_subject, $content, $headers); } } ?>