From: hmurata Date: Sat, 18 Feb 2006 01:06:40 +0000 (+0000) Subject: (smtp-debug): New user option. X-Git-Tag: flim-1_14_9-pre0~16 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88438459f3df16a834c96135db140f58742b07c2;p=elisp%2Fflim.git (smtp-debug): New user option. (smtp-read-response): Treat a line break code loosely. If smtp-debug is non-nil, show an invalid response. --- diff --git a/ChangeLog b/ChangeLog index 34cbe2e..4265f55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-02-18 Hiroya Murata + + * smtp.el (smtp-debug): New user option. + (smtp-read-response): Treat a line break code loosely. If + smtp-debug is non-nil, show an invalid response. + 2005-12-25 Katsumi Yamaoka * eword-decode.el: Change the way to decode successive diff --git a/smtp.el b/smtp.el index 0fcf274..2b54c64 100644 --- a/smtp.el +++ b/smtp.el @@ -148,6 +148,11 @@ For instance, the value \"Sending (%k)...\" shows like (const :tag "Don't show progress message" nil)) :group 'smtp) +(defcustom smtp-debug nil + "*If non-nil, smtp debug info printout into messages." + :type 'boolean + :group 'smtp) + (defvar sasl-mechanisms) ;;;###autoload @@ -455,7 +460,7 @@ BUFFER may be a buffer or a buffer name which contains mail message." (let ((smtp-use-sasl nil) (smtp-use-starttls-ignore-error t)) (funcall smtp-submit-package-function package))) - (setq servers (cdr servers))))) + (setq servers (cdr servers))))) ;;; @ hook methods for `smtp-submit-package' ;;; @@ -653,26 +658,33 @@ BUFFER may be a buffer or a buffer name which contains mail message." response) (while response-continue (goto-char smtp-read-point) - (while (not (search-forward smtp-end-of-line nil t)) + (while (not (re-search-forward "\r?\n" nil t)) (unless (smtp-connection-opened connection) (signal 'smtp-error "Connection closed")) (accept-process-output (smtp-connection-process-internal connection)) (goto-char smtp-read-point)) - (if decoder - (let ((string (buffer-substring smtp-read-point (- (point) 2)))) - (delete-region smtp-read-point (point)) - (insert (funcall decoder string) smtp-end-of-line))) - (setq response - (nconc response - (list (buffer-substring - (+ 4 smtp-read-point) - (- (point) 2))))) - (goto-char - (prog1 smtp-read-point - (setq smtp-read-point (point)))) - (if (looking-at "[1-5][0-9][0-9] ") - (setq response (cons (read (point-marker)) response) - response-continue nil))) + (let ((bol smtp-read-point) + (eol (match-beginning 0)) + (reply-code nil)) + (when decoder + (let ((string (buffer-substring bol eol))) + (delete-region bol (point)) + (insert (funcall decoder string)) + (setq eol (point)) + (insert smtp-end-of-line))) + (setq smtp-read-point (point)) + (goto-char bol) + (if (not (looking-at "[1-5][0-9][0-9]\\([ -]\\)")) + (when smtp-debug + (message "Invalid response: %s" (buffer-substring bol eol))) + (when (string= (match-string 1) " ") + (setq reply-code (read (point-marker)))) + (setq response + (nconc response + (list (buffer-substring (match-end 0) eol)))) + (when reply-code + (setq response (cons reply-code response) + response-continue nil))))) response)) (defun smtp-send-command (connection command)