Commit f0c30abd authored by Penny Leach's avatar Penny Leach

more work on email_user. autodetect noreplyaddress unless it's set

in config.php
parent 03ebbc95
......@@ -47,6 +47,11 @@ $cfg->dbprefix = '';
// this is a big security hole.
$cfg->dataroot = '/path/to/uploaddir';
// system mail address. emails out come from this address.
// if not specified, will default to noreply@ automatically detected host.
// if that doesn't work or you want something else, then specify it here.
// $cfg->noreplyaddress = 'noreply@myhost.com'
// Logging configuration
// For each log level, you can specify where the messages are displayed.
// LOG_TARGET_SCREEN makes the error messages go to the screen - useful
......
......@@ -64,6 +64,13 @@ if (!isset($CFG->wwwroot) && isset($_SERVER['HTTP_HOST'])) {
}
$CFG->wwwroot = $proto . $host . '/' . $path;
}
if (!isset($CFG->noreplyaddress) && isset($_SERVER['HTTP_HOST'])) {
$CFG->noreplyaddress = 'noreply@' .
((isset($_SERVER['HTTP_X_FORWARDED_HOST']))
? $_SERVER['HTTP_X_FORWARDED_HOST']
: $_SERVER['HTTP_HOST']);
error_log("set to $CFG->noreplyaddress");
}
// xmldb stuff
$CFG->xmldbdisablenextprevchecking = true;
......
......@@ -84,4 +84,5 @@ $string['creategroup'] = 'Add new group';
$string['groupname'] = 'Group name';
$string['groupdescription'] = 'Group description';
$string['emailname'] = 'Mahara System'; // robot!
?>
......@@ -802,6 +802,16 @@ function main_nav() {
return $menu;
}
/**
* Always use this function for all emails to users
*
* @param object $userto user object to send email to. must contain firstname,lastname,prefname,email
* @param object $userfrom user object to send email from. If null, email will come from mahara
* @param string $subject email subject
* @param string $messagetext text version of email
* @param string $messagehtml html version of email (will send both html and text)
*/
function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='') {
if (empty($userto)) {
......@@ -858,8 +868,7 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='')
$mail->WordWrap = 79;
// @todo get mail format and check it here before sending html
if ($messagehtml) { // Don't ever send HTML to users who don't want it
if ($messagehtml) {
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
$mail->Body = $messagehtml;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment