From 6265d4630b16d6abe87789b2efdfeb04c40499b0 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 17 Dec 2007 23:44:25 +0000 Subject: [PATCH] MDL-12103 new config option for mail newline chars; merged from MOODLE_19_STABLE --- admin/settings/server.php | 2 ++ lang/en_utf8/admin.php | 2 ++ lib/moodlelib.php | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/admin/settings/server.php b/admin/settings/server.php index 8c2d9ebf7b..278596a801 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -57,6 +57,8 @@ $options['0'] = get_string('none'); $options = array_merge($options, $charsets); $temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset','admin'), '', $options)); $temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0)); +$options = array('LF'=>'LF', 'CRLF'=>'CRLF'); +$temp->add(new admin_setting_configselect('mailnewline', get_string('mailnewline', 'admin'), get_string('configmailnewline','admin'), 'LF', $options)); if (isloggedin()) { global $USER; $primaryadminemail = $USER->email; diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 68a2b64aee..b8206cdf0d 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -138,6 +138,7 @@ $string['configloginhttps'] = 'Turning this on will make Moodle use a secure htt $string['configloglifetime'] = 'This specifies the length of time you want to keep logs about user activity. Logs that are older than this age are automatically deleted. It is best to keep logs as long as possible, in case you need them, but if you have a very busy server and are experiencing performance problems, then you may want to lower the log lifetime.'; $string['configlongtimenosee'] = 'If students haven\'t logged in for a very long time, then they are automatically unsubscribed from courses. This parameter specifies that time limit.'; $string['configlookahead'] = 'Days to Lookahead'; +$string['configmailnewline'] = 'Newline characters used in mail messages. CRLF is required according to RFC 822bis, some mail servers do automatic conversion from LF to CRLF, other mail servers do incorrect conversion from CRLF to CRCRLF, yet others reject mails with bare LF (qmail for example). Try changing this setting if you are having problems with undelivered emails or double newlines.'; $string['configmaxbytes'] = 'This specifies a maximum size that uploaded files can be throughout the whole site. This setting is limited by the PHP settings post_max_size and upload_max_filesize, as well as the Apache setting LimitRequestBody. In turn, maxbytes limits the range of sizes that can be chosen at course level or module level. If \'Server Limit\' is chosen, the server maxiumum allowed by the server will be used.'; $string['configmaxeditingtime'] = 'This specifies the amount of time people have to re-edit forum postings, glossary comments etc. Usually 30 minutes is a good value.'; $string['configmaxevents'] = 'Events to Lookahead'; @@ -405,6 +406,7 @@ $string['loglifetime'] = 'Keep logs for'; $string['longtimenosee'] = 'Unsubscribe users from courses after'; $string['longtimewarning'] = 'Please note that this process can take a long time.'; $string['mail'] = 'Email'; +$string['mailnewline'] = 'Newline characters in mail'; $string['maintfileopenerror'] = 'Error opening maintenance files!'; $string['maintinprogress'] = 'Maintenance is in progress...'; $string['managelang'] = 'Manage'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index bd35af2f3d..528b931f66 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3833,6 +3833,14 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a $mail->CharSet = 'UTF-8'; + // some MTAs may do double conversion of LF if CRLF used, CRLF is required line ending in RFC 822bis + // hmm, this is a bit hacky because LE should be private + if (isset($CFG->mailnewline) and $CFG->mailnewline == 'CRLF') { + $mail->LE = "\r\n"; + } else { + $mail->LE = "\n"; + } + if ($CFG->smtphosts == 'qmail') { $mail->IsQmail(); // use Qmail system -- 2.39.5