Skip to content
Snippets Groups Projects
Commit f08086ec authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Added HTML wrapper for mails

The mailwrap.html adds the standard headers and footers to all HTML
mails. The signature present in the text body will be removed before
inserting in the wrapper, allowing a nicer footer for HTML.

Users can overwrite the file with their own to create HTML mails in
corporate design. However, a way to automatically embed referenced
images is missing currently.
parent 2adaf2b8
No related branches found
No related tags found
No related merge requests found
......@@ -130,13 +130,13 @@ class Mailer {
* If you pass the HTML part or HTML replacements yourself you have to make
* sure you encode all HTML special chars correctly
*
* @fixme the HTML head and body still needs to be set
* @param string $text plain text body
* @param array $textrep replacements to apply on the text part
* @param array $htmlrep replacements to apply on the HTML part, leave null to use $textrep
* @param array $html the HTML body, leave null to create it from $text
* @param bool $wrap wrap the HTML in the default header/Footer
*/
public function setBody($text, $textrep=null, $htmlrep=null, $html=null){
public function setBody($text, $textrep=null, $htmlrep=null, $html=null, $wrap=true){
global $INFO;
global $conf;
$htmlrep = (array) $htmlrep;
......@@ -147,6 +147,12 @@ class Mailer {
$html = hsc($text);
$html = nl2br($text);
}
if($wrap){
$wrap = rawLocale('mailwrap','html');
$html = preg_replace('/\n-- \n.*$/m','',$html); //strip signature
$html = str_replace('@HTMLBODY@',$html,$wrap);
}
// copy over all replacements missing for HTML (autolink URLs)
foreach($textrep as $key => $value){
if(isset($htmlrep[$key])) continue;
......@@ -159,11 +165,12 @@ class Mailer {
// prepare default replacements
$ip = clientIP();
$cip = gethostsbyaddrs($ip);
$trep = array(
'DATE' => dformat(),
'BROWSER' => $_SERVER['HTTP_USER_AGENT'],
'IPADDRESS' => $ip,
'HOSTNAME' => gethostsbyaddrs($ip),
'HOSTNAME' => $cip,
'TITLE' => $conf['title'],
'DOKUWIKIURL' => DOKU_URL,
'USER' => $_SERVER['REMOTE_USER'],
......@@ -175,7 +182,7 @@ class Mailer {
'DATE' => '<i>'.hsc(dformat()).'</i>',
'BROWSER' => hsc($_SERVER['HTTP_USER_AGENT']),
'IPADDRESS' => '<code>'.hsc($ip).'</code>',
'HOSTNAME' => '<code>'.hsc(gethostsbyaddrs($ip)).'</code>',
'HOSTNAME' => '<code>'.hsc($cip).'</code>',
'TITLE' => hsc($conf['title']),
'DOKUWIKIURL' => '<a href="'.DOKU_URL.'">'.DOKU_URL.'</a>',
'USER' => hsc($_SERVER['REMOTE_USER']),
......
<html>
<head>
<title>@TITLE@</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
@HTMLBODY@
<br /><br /><hr />
<small>This mail was generated by DokuWiki at @DOKUWIKIURL@.</small>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment