Skip to content
Snippets Groups Projects
Commit 3e37e226 authored by Jason Flatt's avatar Jason Flatt
Browse files

Adding options for specifying how to connect to secure mail servers.

parent 6453e0e5
Branches
Tags
No related merge requests found
......@@ -65,6 +65,10 @@ class DrupalPHPMailer extends PHPMailer implements MailSystemInterface {
$this->Port = variable_get('smtp_port', '25');
$this->SMTPSecure = variable_get('smtp_protocol', '');
$this->SMTPOptions['ssl']['verify_peer'] = variable_get('ssl_verify_peer', 1);
$this->SMTPOptions['ssl']['verify_peer_name'] = variable_get('ssl_verify_peer_name', 1);
$this->SMTPOptions['ssl']['allow_self_signed'] = variable_get('ssl_allow_self_signed', 0);
// Use SMTP authentication if both username and password are given.
$this->Username = variable_get('smtp_username', '');
$this->Password = variable_get('smtp_password', '');
......
......@@ -133,6 +133,35 @@ function phpmailer_settings_form($form, $form_state) {
'#description' => t("Debug the communication with the SMTP server. You normally shouldn't enable this unless you're trying to debug e-mail sending problems."),
);
$form['advanced']['ssl_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced SSL settings'),
'#description' => t('If you are attempting to connect to a broken or malconfigured secure mail server, you can try toggling one or more of the following. If that allows the connection, consider fixing the SSL certifcate, as it may be insecure.'),
);
$form['advanced']['ssl_settings']['ssl_verify_peer'] = array(
'#type' => 'checkbox',
'#title' => t('Verfy peer'),
'#default_value' => variable_get('ssl_verify_peer', 1),
'#description' => t('If this is checked, it will require verification of the SSL certificate being used on the mail server.'),
);
$form['advanced']['ssl_settings']['ssl_verify_peer_name'] = array(
'#type' => 'checkbox',
'#title' => t('Verfy peer name'),
'#default_value' => variable_get('ssl_verify_peer_name', 1),
'#description' => t("If this is checked, it will require verification of the mail server's name in the SSL certificate."),
);
$form['advanced']['ssl_settings']['ssl_allow_self_signed'] = array(
'#type' => 'checkbox',
'#title' => t('Allow self signed'),
'#default_value' => variable_get('ssl_allow_self_signed', 0),
'#description' => t('If this is checked, it will allow conecting to a mail server with a self-signed SSL certificate. (This requires "Verfy peer" to be enabled.)'),
'#states' => array(
'enabled' => array(
':input[name="ssl_verify_peer"]' => array('checked' => TRUE),
),
),
);
// Send a test email message if an address has been entered.
if ($test_address = variable_get('phpmailer_test', '')) {
// Delete first to avoid unintended resending in case of an error.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment