From 2108ac8a4faf18b37d14dd14a77b0d262eba67f2 Mon Sep 17 00:00:00 2001 From: Daniel Neis Date: Wed, 13 May 2015 18:06:21 -0300 Subject: [PATCH] MDL-30960 messages: add option to set authtype --- lib/phpmailer/moodle_phpmailer.php | 4 ++++ message/output/email/lang/en/message_email.php | 2 ++ message/output/email/settings.php | 2 ++ 3 files changed, 8 insertions(+) diff --git a/lib/phpmailer/moodle_phpmailer.php b/lib/phpmailer/moodle_phpmailer.php index 0ad17fa6860..b502d4a22a3 100644 --- a/lib/phpmailer/moodle_phpmailer.php +++ b/lib/phpmailer/moodle_phpmailer.php @@ -53,6 +53,10 @@ class moodle_phpmailer extends PHPMailer { $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"; diff --git a/message/output/email/lang/en/message_email.php b/message/output/email/lang/en/message_email.php index a276f2e2837..a2aec01b951 100644 --- a/message/output/email/lang/en/message_email.php +++ b/message/output/email/lang/en/message_email.php @@ -30,6 +30,7 @@ $string['configmailnewline'] = 'Newline characters used in mail messages. CRLF i $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.'; @@ -42,6 +43,7 @@ $string['none'] = 'None'; $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'; diff --git a/message/output/email/settings.php b/message/output/email/settings.php index 242fcf8fa82..69f58dca354 100644 --- a/message/output/email/settings.php +++ b/message/output/email/settings.php @@ -28,6 +28,8 @@ if ($ADMIN->fulltree) { $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));