From 19862b5586343205dc381339bfea46915dd498d3 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Tue, 14 Jul 2009 12:34:34 -0400 Subject: [PATCH] - added 'smtp_debug' option --- CHANGELOG | 2 +- program/include/rcube_smtp.inc | 9 +++++++++ config/main.inc.php.dist | 3 +++ 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index dbcde26..2ec9a71 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,7 +5,7 @@ - Added hook to write_log function (#1485971) - Performance improvements by use UID commands (#1485690) - Fix HTML editor tabIndex setting (#1485972) -- Added 'imap_debug' option +- Added 'imap_debug' and 'smtp_debug' options - Support strftime's format modifiers in date_* options (#1484806) - Support %h variable in 'smtp_server' option (#1485766) - Show SMTP errors in browser (#1485927) diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist index b7bf2ad..6050a4a 100644 --- a/config/main.inc.php.dist +++ b/config/main.inc.php.dist @@ -130,6 +130,9 @@ // Log IMAP conversation to <log_dir>/imap or to syslog $rcmail_config['imap_debug'] = false; +// Log SMTP conversation to <log_dir>/smtp or to syslog +$rcmail_config['smtp_debug'] = false; + // How many seconds must pass between emails sent by a user $rcmail_config['sendmail_delay'] = 0; diff --git a/program/include/rcube_smtp.inc b/program/include/rcube_smtp.inc index db681af..9e1e664 100644 --- a/program/include/rcube_smtp.inc +++ b/program/include/rcube_smtp.inc @@ -92,6 +92,9 @@ $SMTP_CONN = new Net_SMTP($smtp_host, $smtp_port, $helo_host); + if($RCMAIL->config->get('smtp_debug')) + $SMTP_CONN->setDebug(true, 'smtp_debug_handler'); + // try to connect to server and exit on failure $result = $SMTP_CONN->connect($smtp_timeout); if (PEAR::isError($result)) @@ -247,6 +250,12 @@ } } +/* this is our own debug handler for the SMTP connection */ +function smtp_debug_handler(&$smtp, $message) + { + write_log('smtp', preg_replace('/\r\n$/', '', $message)); + } + /** * Take an array of mail headers and return a string containing -- Gitblit v1.9.1