Feature Issue ID 0000598:
Possibility to send HTML mail git-svn-id: http://piwigo.org/svn/trunk@1642 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
961640b8d6
commit
92fc9abb14
6 changed files with 170 additions and 8 deletions
|
|
@ -224,6 +224,11 @@ $conf['send_bcc_mail_webmaster'] = false;
|
|||
// There are webhosting wich not allow email formatted (Lycos, ...)
|
||||
$conf['enabled_format_email'] = true;
|
||||
|
||||
// default_email_format:
|
||||
// Define the default email format use to send email
|
||||
// Value could be text/plain or text/html
|
||||
$conf['default_email_format'] = 'text/plain';
|
||||
|
||||
// check_upgrade_feed: check if there are database upgrade required. Set to
|
||||
// true, a message will strongly encourage you to upgrade your database if
|
||||
// needed.
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ function get_mail_configuration()
|
|||
$conf_mail = array(
|
||||
'mail_options' => $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 ?
|
||||
|
|
@ -102,9 +103,9 @@ function format_email($name, $email)
|
|||
/**
|
||||
* sends an email, using PhpWebGallery specific informations
|
||||
*/
|
||||
function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
|
||||
function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $format_infos = 'text/plain', $email_format = null)
|
||||
{
|
||||
global $conf, $conf_mail, $lang_info;
|
||||
global $conf, $conf_mail, $lang_info, $user;
|
||||
|
||||
$cvt7b_subject = str_translate_to_ascii7bits($subject);
|
||||
|
||||
|
|
@ -113,6 +114,17 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
|
|||
$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;
|
||||
}
|
||||
|
||||
$to = format_email('', $to);
|
||||
|
||||
if ($from == '')
|
||||
|
|
@ -126,7 +138,7 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
|
|||
|
||||
$headers = 'From: '.$from."\n";
|
||||
$headers.= 'Reply-To: '.$from."\n";
|
||||
$headers.= 'Content-Type: text/plain;format=flowed;charset="'.$lang_info['charset'].'";';
|
||||
$headers.= 'Content-Type: '.$email_format.';format=flowed;charset="'.$lang_info['charset'].'";';
|
||||
$headers.= 'reply-type=original'."\n";
|
||||
|
||||
if ($conf_mail['send_bcc_mail_webmaster'])
|
||||
|
|
@ -134,8 +146,57 @@ function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
|
|||
$headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
|
||||
}
|
||||
|
||||
$content = $infos;
|
||||
$content.= $conf_mail['text_footer'];
|
||||
list($tmpl, $thm) = explode('/', $conf['default_template']);
|
||||
$template_mail = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
|
||||
|
||||
$content = '';
|
||||
|
||||
if ($email_format == 'text/html')
|
||||
{
|
||||
$template_mail->set_filenames(array('mail_header'=>'mail/header.tpl'));
|
||||
|
||||
$template_mail->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']
|
||||
|
||||
));
|
||||
|
||||
$content.= $template_mail->parse('mail_header', true);
|
||||
}
|
||||
|
||||
if (($format_infos == 'text/plain') and ($email_format == 'text/html'))
|
||||
{
|
||||
$content.= '<pre>'.htmlentities($infos).'</pre>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$content.= $infos;
|
||||
}
|
||||
|
||||
if ($email_format == 'text/plain')
|
||||
{
|
||||
$content.= $conf_mail['text_footer'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$template_mail->set_filenames(array('mail_footer'=>'footer.tpl'));
|
||||
|
||||
$template_mail->assign_vars(
|
||||
array(
|
||||
'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
|
||||
|
||||
'L_TITLE_MAIL' => urlencode(l10n('title_send_mail')),
|
||||
'MAIL' => get_webmaster_mail_address()
|
||||
));
|
||||
|
||||
$content.= $template_mail->parse('mail_footer', true);
|
||||
}
|
||||
|
||||
if ($conf_mail['mail_options'])
|
||||
{
|
||||
|
|
|
|||
35
template/yoga/mail/admin/index.php
Normal file
35
template/yoga/mail/admin/index.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2006-03-15 23:44:35 +0100 (mer., 15 mars 2006) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 1082 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// recursive call of index.php
|
||||
|
||||
$url = '../index.php';
|
||||
header( 'Request-URI: '.$url );
|
||||
header( 'Content-Location: '.$url );
|
||||
header( 'Location: '.$url );
|
||||
exit();
|
||||
?>
|
||||
16
template/yoga/mail/footer.tpl
Normal file
16
template/yoga/mail/footer.tpl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<div id="copyright">
|
||||
|
||||
<!-- Please, do not remove this copyright. If you really want to,
|
||||
contact us on http://phpwebgallery.net to find a solution on how
|
||||
to show the origin of the script...-->
|
||||
|
||||
{lang:powered_by} <a href="http://www.phpwebgallery.net" class="back">PhpWebGallery</a>
|
||||
{VERSION}
|
||||
- {lang:send_mail}
|
||||
<a href="mailto:{contact.MAIL}?subject={L_TITLE_MAIL}">{lang:Webmaster}</a>
|
||||
|
||||
</div> <!-- copyright -->
|
||||
</div> <!-- the_page -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
10
template/yoga/mail/header.tpl
Normal file
10
template/yoga/mail/header.tpl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="{LANG}" dir="{DIR}">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset={CONTENT_ENCODING}">
|
||||
</head>
|
||||
|
||||
<body id="{BODY_ID}">
|
||||
<div id="the_mail">
|
||||
|
||||
35
template/yoga/mail/index.php
Normal file
35
template/yoga/mail/index.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2006-03-15 23:44:35 +0100 (mer., 15 mars 2006) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 1082 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// recursive call of index.php
|
||||
|
||||
$url = '../index.php';
|
||||
header( 'Request-URI: '.$url );
|
||||
header( 'Content-Location: '.$url );
|
||||
header( 'Location: '.$url );
|
||||
exit();
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue