? phpmailer/class.phpmailer.php
? phpmailer/class.smtp.php
Index: phpmailer.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/phpmailer/phpmailer.admin.inc,v
retrieving revision 1.15.2.4
diff -u -p -r1.15.2.4 phpmailer.admin.inc
--- phpmailer.admin.inc	17 Jan 2010 18:04:49 -0000	1.15.2.4
+++ phpmailer.admin.inc	19 May 2010 19:34:58 -0000
@@ -138,6 +138,12 @@ function phpmailer_settings_form() {
     '#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_to_file'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Log debug info to file also'),
+    '#default_value' => variable_get('smtp_debug_log_to_file', 0),
+    '#description' => t("Should the debug info be logged also to a file? It's specially usefull for emails sent automatically, via cron or similar. Logs to a file named \"phpmailer_debug.log\" in the site’s temp directory which seems to be <%temp_path>.", array('%temp_path' => file_directory_temp())),
+  );
 
   // Send a test email message if an address has been entered.
   if ($test_address = variable_get('phpmailer_test', '')) {
Index: includes/phpmailer.class.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/phpmailer/includes/phpmailer.class.inc,v
retrieving revision 1.13.2.5
diff -u -p -r1.13.2.5 phpmailer.class.inc
--- includes/phpmailer.class.inc	17 Jan 2010 15:02:54 -0000	1.13.2.5
+++ includes/phpmailer.class.inc	19 May 2010 19:34:59 -0000
@@ -44,6 +44,7 @@ class DrupalPHPMailer extends PHPMailer 
 
     $this->SMTPKeepAlive = variable_get('smtp_keepalive', 0);
     $this->SMTPDebug = variable_get('smtp_debug', 0);
+    $this->SMTPDebugToFile = variable_get('smtp_debug_log_to_file', 0);
 
     // Adjust path to SMTP class.
     $this->PluginDir = drupal_get_path('module', 'phpmailer') . '/phpmailer/';
@@ -67,6 +68,12 @@ class DrupalPHPMailer extends PHPMailer 
     if ($this->SMTPDebug) {
       if ($debug = ob_get_contents()) {
         drupal_set_message($debug);
+        if($this->SMTPDebugToFile) {
+          $file = file_directory_temp() .'/phpmailer_debug.log';
+          if (file_put_contents($file, $debug, FILE_APPEND) === FALSE) {
+            drupal_set_message(t("The SMTP debug log file <%file> could not be written.", array('%file' => $file)), 'error');
+          }
+        }
       }
       ob_end_clean();
     }
