diff options
-rw-r--r-- | inc/Mailer.class.php | 22 | ||||
-rw-r--r-- | inc/lang/en/mailwrap.html | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index cdd4b266a..7e6889292 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -87,6 +87,24 @@ class Mailer { } /** + * Callback function to automatically embed images referenced in HTML templates + */ + protected function autoembed_cb($matches){ + static $embeds = 0; + $embeds++; + + // get file and mime type + $media = cleanID($matches[1]); + list($ext, $mime) = mimetype($media); + $file = mediaFN($media); + if(!file_exists($file)) return $matches[0]; //bad reference, keep as is + + // attach it and set placeholder + $this->attachFile($file,$mime,'','autoembed'.$embeds); + return '%%autoembed'.$embeds.'%%'; + } + + /** * Add an arbitrary header to the mail * * If an empy value is passed, the header is removed @@ -163,6 +181,10 @@ class Mailer { } } + // embed media from templates + $html = preg_replace_callback('/@MEDIA\(([^\)]+)\)@/', + array($this,'autoembed_cb'),$html); + // prepare default replacements $ip = clientIP(); $cip = gethostsbyaddrs($ip); diff --git a/inc/lang/en/mailwrap.html b/inc/lang/en/mailwrap.html index d67644c95..00daf29ac 100644 --- a/inc/lang/en/mailwrap.html +++ b/inc/lang/en/mailwrap.html @@ -8,6 +8,7 @@ @HTMLBODY@ <br /><br /><hr /> +<img src="@MEDIA(wiki:dokuwiki-128.png)@" width="32" height="32" alt="DokuWiki" align="left" /> <small>This mail was generated by DokuWiki at @DOKUWIKIURL@.</small> </body> </html> |