Commit 9b888b50 authored by oadaeh's avatar oadaeh Committed by oadaeh

Issue #2088807 by oadaeh: Log SMTP communication output

parent 4520ecc4
......@@ -77,7 +77,7 @@ class DrupalPHPMailer extends PHPMailer implements MailSystemInterface {
$this->SMTPKeepAlive = variable_get('smtp_keepalive', 0);
$this->drupalDebug = variable_get('smtp_debug', 0);
if ($this->drupalDebug > $this->SMTPDebug) {
if ($this->drupalDebug > $this->SMTPDebug && user_access('administer phpmailer settings')) {
$this->SMTPDebug = $this->drupalDebug;
}
......@@ -110,6 +110,9 @@ class DrupalPHPMailer extends PHPMailer implements MailSystemInterface {
if ($this->SMTPDebug) {
if ($this->drupalDebug && ($this->drupalDebugOutput = ob_get_contents())) {
drupal_set_message($this->drupalDebugOutput);
if (variable_get('smtp_debug_log', 0)) {
watchdog('phpmailer', 'Output of communication with SMTP server:<br /><pre>!output</pre>', array('!output' => print_r($this->drupalDebugOutput, TRUE)), WATCHDOG_DEBUG);
}
}
ob_end_clean();
}
......
......@@ -143,6 +143,17 @@ function phpmailer_settings_form($form, $form_state) {
'#options' => array(0 => t('Disabled'), 1 => t('Errors only'), 2 => t('Server responses'), 4 => t('Full communication')),
'#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']['smtp_debug_log'] = array(
'#type' => 'checkbox',
'#title' => t("Record debugging output in Drupal's log"),
'#default_value' => variable_get('smtp_debug_log', 0),
'#description' => t("If this is checked, the debugging out put that is produced will also be recorded in Drupal's database log."),
'#states' => array(
'visible' => array(
':input[name=smtp_debug]' => array('!value' => 0),
),
),
);
$form['advanced']['ssl_settings'] = array(
'#type' => 'fieldset',
......
......@@ -75,6 +75,7 @@ function phpmailer_uninstall() {
variable_del('smtp_password');
variable_del('smtp_keepalive');
variable_del('smtp_debug');
variable_del('smtp_debug_log');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment