diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-08-18 09:53:40 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-08-18 09:53:40 +0200 |
commit | 570d58dd646b5b301befb8d21fb567adb09c0cb0 (patch) | |
tree | e2e17af815a79e09424c83d5aca1fd4f07845f79 /inc | |
parent | c0ec69288a7ae838ba9f3da6cc5069d6abe33e15 (diff) | |
parent | 465e809be9a7b9bbf06feb7f47814582eadb0cf4 (diff) | |
download | rpg-570d58dd646b5b301befb8d21fb567adb09c0cb0.tar.gz rpg-570d58dd646b5b301befb8d21fb567adb09c0cb0.tar.bz2 |
Merge branch 'noreply'
* noreply:
renamed mailfromnon to mailfromnobody, use in subscriptions
added mailfromnone internal option FS#2170
Conflicts:
inc/subscription.php
Diffstat (limited to 'inc')
-rw-r--r-- | inc/mail.php | 28 | ||||
-rw-r--r-- | inc/subscription.php | 2 |
2 files changed, 23 insertions, 7 deletions
diff --git a/inc/mail.php b/inc/mail.php index bec0c5b10..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; } /** diff --git a/inc/subscription.php b/inc/subscription.php index 1f1aedfa4..1bee1152e 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -392,6 +392,7 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) { */ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) { global $lang; + global $conf; $text = rawLocale($template); $trep = array_merge($replaces, array('PAGE' => $id)); @@ -401,6 +402,7 @@ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template $mail->bcc($subscriber_mail); $mail->subject($subject); $mail->setBody($text,$trep); + $mail->from($conf['mailfromnobody']); $mail->setHeader( 'List-Unsubscribe', '<'.wl($id,array('do'=>'subscribe'),true,'&').'>', |