summaryrefslogtreecommitdiff
path: root/inc/mail.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/mail.php')
-rw-r--r--inc/mail.php34
1 files changed, 24 insertions, 10 deletions
diff --git a/inc/mail.php b/inc/mail.php
index 01b2895e1..d0ea651bf 100644
--- a/inc/mail.php
+++ b/inc/mail.php
@@ -32,20 +32,25 @@ if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '['
/**
* Prepare mailfrom replacement patterns
*
+ * Also prepares a mailfromnobody config that contains an autoconstructed address
+ * if the mailfrom one is userdependent and this might not be wanted (subscriptions)
+ *
* @author Andreas Gohr <andi@splitbrain.org>
*/
function mail_setup(){
global $conf;
global $USERINFO;
- $replace = array();
+ // auto constructed address
+ $host = @parse_url(DOKU_URL,PHP_URL_HOST);
+ if(!$host) $host = 'example.com';
+ $noreply = 'noreply@'.$host;
+ $replace = array();
if(!empty($USERINFO['mail'])){
$replace['@MAIL@'] = $USERINFO['mail'];
}else{
- $host = @parse_url(DOKU_URL,PHP_URL_HOST);
- if(!$host) $host = 'example.com';
- $replace['@MAIL@'] = 'noreply@'.$host;
+ $replace['@MAIL@'] = $noreply;
}
if(!empty($_SERVER['REMOTE_USER'])){
@@ -60,9 +65,18 @@ function mail_setup(){
$replace['@NAME@'] = '';
}
- $conf['mailfrom'] = str_replace(array_keys($replace),
- array_values($replace),
- $conf['mailfrom']);
+ // apply replacements
+ $from = str_replace(array_keys($replace),
+ array_values($replace),
+ $conf['mailfrom']);
+
+ // any replacements done? set different mailfromnone
+ if($from != $conf['mailfrom']){
+ $conf['mailfromnobody'] = $noreply;
+ }else{
+ $conf['mailfromnobody'] = $from;
+ }
+ $conf['mailfrom'] = $from;
}
/**
@@ -106,7 +120,7 @@ function _mail_send_action($data) {
// discard mail request if no recipients are available
if(trim($to) === '' && trim($cc) === '' && trim($bcc) === '') return false;
-
+
// end additional code to support event ... original mail_send() code from here
if(defined('MAILHEADER_ASCIIONLY')){
@@ -208,9 +222,9 @@ function mail_encode_address($string,$header='',$names=true){
if(!utf8_isASCII($text)){
// put the quotes outside as in =?UTF-8?Q?"Elan Ruusam=C3=A4e"?= vs "=?UTF-8?Q?Elan Ruusam=C3=A4e?="
if (preg_match('/^"(.+)"$/', $text, $matches)) {
- $text = '"=?UTF-8?Q?'.mail_quotedprintable_encode($matches[1], 0).'?="';
+ $text = '"=?UTF-8?Q?'.mail_quotedprintable_encode($matches[1], 0).'?="';
} else {
- $text = '=?UTF-8?Q?'.mail_quotedprintable_encode($text, 0).'?=';
+ $text = '=?UTF-8?Q?'.mail_quotedprintable_encode($text, 0).'?=';
}
// additionally the space character should be encoded as =20 (or each
// word QP encoded separately).