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

Merge branch 'noreply'

* noreply:
  renamed mailfromnon to mailfromnobody, use in subscriptions
  added mailfromnone internal option FS#2170

Conflicts:
	inc/subscription.php
parents c0ec6928 465e809b
No related branches found
No related tags found
No related merge requests found
...@@ -32,20 +32,25 @@ if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '[' ...@@ -32,20 +32,25 @@ if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '['
/** /**
* Prepare mailfrom replacement patterns * 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> * @author Andreas Gohr <andi@splitbrain.org>
*/ */
function mail_setup(){ function mail_setup(){
global $conf; global $conf;
global $USERINFO; 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'])){ if(!empty($USERINFO['mail'])){
$replace['@MAIL@'] = $USERINFO['mail']; $replace['@MAIL@'] = $USERINFO['mail'];
}else{ }else{
$host = @parse_url(DOKU_URL,PHP_URL_HOST); $replace['@MAIL@'] = $noreply;
if(!$host) $host = 'example.com';
$replace['@MAIL@'] = 'noreply@'.$host;
} }
if(!empty($_SERVER['REMOTE_USER'])){ if(!empty($_SERVER['REMOTE_USER'])){
...@@ -60,9 +65,18 @@ function mail_setup(){ ...@@ -60,9 +65,18 @@ function mail_setup(){
$replace['@NAME@'] = ''; $replace['@NAME@'] = '';
} }
$conf['mailfrom'] = str_replace(array_keys($replace), // apply replacements
array_values($replace), $from = str_replace(array_keys($replace),
$conf['mailfrom']); 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;
} }
/** /**
......
...@@ -392,6 +392,7 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) { ...@@ -392,6 +392,7 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) {
*/ */
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) { function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) {
global $lang; global $lang;
global $conf;
$text = rawLocale($template); $text = rawLocale($template);
$trep = array_merge($replaces, array('PAGE' => $id)); $trep = array_merge($replaces, array('PAGE' => $id));
...@@ -401,6 +402,7 @@ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template ...@@ -401,6 +402,7 @@ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template
$mail->bcc($subscriber_mail); $mail->bcc($subscriber_mail);
$mail->subject($subject); $mail->subject($subject);
$mail->setBody($text,$trep); $mail->setBody($text,$trep);
$mail->from($conf['mailfromnobody']);
$mail->setHeader( $mail->setHeader(
'List-Unsubscribe', 'List-Unsubscribe',
'<'.wl($id,array('do'=>'subscribe'),true,'&').'>', '<'.wl($id,array('do'=>'subscribe'),true,'&').'>',
......
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