summaryrefslogtreecommitdiff
path: root/inc/Mailer.class.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-11-13 12:37:45 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-11-13 12:40:36 +0100
commitf08086ec453c4529ae7361f9540b430ee61238f0 (patch)
tree61fc7dc023e6fb23e5fdac72526be81ff5325be7 /inc/Mailer.class.php
parent2adaf2b8a608f4a1ac3fe0dba94ff28d7a0d48e5 (diff)
downloadrpg-f08086ec453c4529ae7361f9540b430ee61238f0.tar.gz
rpg-f08086ec453c4529ae7361f9540b430ee61238f0.tar.bz2
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.
Diffstat (limited to 'inc/Mailer.class.php')
-rw-r--r--inc/Mailer.class.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php
index 09e457243..cdd4b266a 100644
--- a/inc/Mailer.class.php
+++ b/inc/Mailer.class.php
@@ -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']),