Skip to content

Commit

Permalink
MDL-30960 messages: add option to set authtype
Browse files Browse the repository at this point in the history
  • Loading branch information
danielneis committed May 25, 2015
1 parent 803f565 commit 2108ac8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/phpmailer/moodle_phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public function __construct(){
$this->Version = 'Moodle '.$CFG->version; // mailer version
$this->CharSet = 'UTF-8';

if (!empty($CFG->smtpauthtype)) {
$this->AuthType = $CFG->smtpauthtype;
}

// Some MTAs may do double conversion of LF if CRLF used, CRLF is required line ending in RFC 822bis.
if (isset($CFG->mailnewline) and $CFG->mailnewline == 'CRLF') {
$this->LE = "\r\n";
Expand Down
2 changes: 2 additions & 0 deletions message/output/email/lang/en/message_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
$string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the "From" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).';
$string['configemailonlyfromnoreplyaddress'] = 'If enabled, all email will be sent using the no-reply address as the "from" address. This can be used to stop anti-spoofing controls in external mail systems blocking emails.';
$string['configsitemailcharset'] = 'This setting specifies the default charset for all emails sent from the site.';
$string['configsmtpauthtype'] = 'This sets the authentication type to use on smtp server.';
$string['configsmtphosts'] = 'Give the full name of one or more local SMTP servers that Moodle should use to send mail (eg \'mail.a.com\' or \'mail.a.com;mail.b.com\'). To specify a non-default port (i.e other than port 25), you can use the [server]:[port] syntax (eg \'mail.a.com:587\'). For secure connections, port 465 is usually used with SSL, port 587 is usually used with TLS, specify security protocol below if required. If you leave this field blank, Moodle will use the PHP default method of sending mail.';
$string['configsmtpmaxbulk'] = 'Maximum number of messages sent per SMTP session. Grouping messages may speed up the sending of emails. Values lower than 2 force creation of new SMTP session for each email.';
$string['configsmtpsecure'] = 'If SMTP server requires secure connection, specify the correct protocol type.';
Expand All @@ -42,6 +43,7 @@
$string['noreplyaddress'] = 'No-reply address';
$string['pluginname'] = 'Email';
$string['sitemailcharset'] = 'Character set';
$string['smtpauthtype'] = 'SMTP Auth Type';
$string['smtphosts'] = 'SMTP hosts';
$string['smtpmaxbulk'] = 'SMTP session limit';
$string['smtppass'] = 'SMTP password';
Expand Down
2 changes: 2 additions & 0 deletions message/output/email/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
$settings->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'message_email'), get_string('configsmtphosts', 'message_email'), '', PARAM_RAW));
$options = array('' => get_string('none', 'message_email'), 'ssl' => 'SSL', 'tls' => 'TLS');
$settings->add(new admin_setting_configselect('smtpsecure', get_string('smtpsecure', 'message_email'), get_string('configsmtpsecure', 'message_email'), '', $options));
$authtypeoptions = array('LOGIN' => 'LOGIN', 'PLAIN' => 'PLAIN', 'NTLM' => 'NTLM', 'CRAM-MD5' => 'CRAM-MD5');
$settings->add(new admin_setting_configselect('smtpauthtype', get_string('smtpauthtype', 'message_email'), get_string('configsmtpauthtype', 'message_email'), 'LOGIN', $authtypeoptions));
$settings->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'message_email'), get_string('configsmtpuser', 'message_email'), '', PARAM_NOTAGS));
$settings->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'message_email'), get_string('configsmtpuser', 'message_email'), ''));
$settings->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'message_email'), get_string('configsmtpmaxbulk', 'message_email'), 1, PARAM_INT));
Expand Down

0 comments on commit 2108ac8

Please sign in to comment.