# HG changeset patch # User meillo@marmaro.de # Date 1279118117 -7200 # Node ID 6530806d418f324e7e95d22dc03948ad2ee1b510 # Parent a39c8ee611857f9f75cd389393213115b73db0e8 better debug logging of outgoing SMTP dialogs the dialog is logged in the style of the RFC examples: ``C: foo'' is said by the client, ``S: bar'' is said by the server debug level 4 is used, but login data is logged on level 6 diff -r a39c8ee61185 -r 6530806d418f src/smtp_out.c --- a/src/smtp_out.c Wed Jul 14 16:26:12 2010 +0200 +++ b/src/smtp_out.c Wed Jul 14 16:35:17 2010 +0200 @@ -174,6 +174,9 @@ buf_pos += len; } while (code[3] == '-'); + if (psb->buffer) { + DEBUG(4) debugf("S: %s\n", psb->buffer); + } return TRUE; } @@ -294,13 +297,13 @@ fprintf(psb->out, "EHLO %s\r\n", helo); fflush(psb->out); - DEBUG(4) debugf("EHLO %s\r\n", helo); + DEBUG(4) debugf("C: EHLO %s\r\n", helo); } else { fprintf(psb->out, "HELO %s\r\n", helo); fflush(psb->out); - DEBUG(4) debugf("HELO %s\r\n", helo); + DEBUG(4) debugf("C: HELO %s\r\n", helo); } @@ -331,13 +334,13 @@ fprintf(psb->out, "MAIL FROM:%s SIZE=%d\r\n", addr_string(return_path), size); fflush(psb->out); - DEBUG(4) debugf("MAIL FROM:%s SIZE=%d\r\n", addr_string(return_path), size); + DEBUG(4) debugf("C: MAIL FROM:%s SIZE=%d\r\n", addr_string(return_path), size); } else { fprintf(psb->out, "MAIL FROM:%s\r\n", addr_string(return_path)); fflush(psb->out); - DEBUG(4) debugf("MAIL FROM:%s\r\n", addr_string(return_path)); + DEBUG(4) debugf("C: MAIL FROM:%s\r\n", addr_string(return_path)); } } @@ -346,7 +349,7 @@ { fprintf(psb->out, "RCPT TO:%s\r\n", addr_string(rcpt)); fflush(psb->out); - DEBUG(4) debugf("RCPT TO:%s\n", addr_string(rcpt)); + DEBUG(4) debugf("C: RCPT TO:%s\n", addr_string(rcpt)); } static void @@ -426,6 +429,7 @@ fprintf(psb->out, ".\r\n"); fflush(psb->out); + DEBUG(4) debugf("C: .\n"); } void @@ -525,7 +529,7 @@ fprintf(psb->out, "RSET\r\n"); fflush(psb->out); - DEBUG(4) debugf("RSET\n"); + DEBUG(4) debugf("C: RSET\n"); if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) if (check_response(psb, FALSE)) @@ -543,7 +547,7 @@ { gboolean ok = FALSE; - fprintf(psb->out, "AUTH CRAM-MD5\r\n"); + fprintf(psb->out, "C: AUTH CRAM-MD5\r\n"); fflush(psb->out); DEBUG(4) debugf("AUTH CRAM-MD5\n"); if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) { @@ -583,7 +587,8 @@ fprintf(psb->out, "%s\r\n", reply64); fflush(psb->out); - DEBUG(4) debugf(" reply64 = %s\n", reply64); + DEBUG(6) debugf(" reply64 = %s\n", reply64); + DEBUG(6) debugf("C: %s\n", reply64); if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) ok = check_response(psb, FALSE); @@ -603,6 +608,7 @@ gboolean ok = FALSE; fprintf(psb->out, "AUTH LOGIN\r\n"); fflush(psb->out); + DEBUG(4) debugf("C: AUTH LOGIN\r\n"); if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) { if ((ok = check_response(psb, TRUE))) { gchar *resp64; @@ -620,6 +626,7 @@ reply64 = base64_encode(psb->auth_login, strlen(psb->auth_login)); fprintf(psb->out, "%s\r\n", reply64); fflush(psb->out); + DEBUG(6) debugf("C: %s\n", reply64); g_free(reply64); if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) { if ((ok = check_response(psb, TRUE))) { @@ -632,6 +639,7 @@ reply64 = base64_encode(psb->auth_secret, strlen(psb->auth_secret)); fprintf(psb->out, "%s\r\n", reply64); fflush(psb->out); + DEBUG(6) debugf("C: %s\n", reply64); g_free(reply64); if ((ok = read_response(psb, SMTP_CMD_TIMEOUT))) ok = check_response(psb, FALSE); @@ -775,7 +783,7 @@ fprintf(psb->out, "DATA\r\n"); fflush(psb->out); - DEBUG(4) debugf("DATA\r\n"); + DEBUG(4) debugf("C: DATA\r\n"); if (psb->use_pipelining) { /* the first pl'ed command was MAIL FROM @@ -879,7 +887,7 @@ fprintf(psb->out, "QUIT\r\n"); fflush(psb->out); - DEBUG(4) debugf("QUIT\n"); + DEBUG(4) debugf("C: QUIT\n"); signal(SIGALRM, SIG_DFL);