$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;
$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';
$string['longtimenosee'] = 'Unsubscribe users from courses after';
$string['longtimewarning'] = '<b>Please note that this process can take a long time.</b>';
$string['mail'] = 'Email';
+$string['mailnewline'] = 'Newline characters in mail';
$string['maintfileopenerror'] = 'Error opening maintenance files!';
$string['maintinprogress'] = 'Maintenance is in progress...';
$string['managelang'] = 'Manage';
$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