summaryrefslogtreecommitdiff
path: root/lisp/mail/smtpmail.el
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen <larsi@gnus.org>2011-06-22 00:33:44 +0200
committerLars Magne Ingebrigtsen <larsi@gnus.org>2011-06-22 00:33:44 +0200
commit7d36ad4669e790e53f51aef772f6e62a6860f4c0 (patch)
tree2044e23ff0832b2f345f4b88a07ad65da9ea7118 /lisp/mail/smtpmail.el
parent183a6951a6ea741ce3aa374a81e7d7ab099e5c12 (diff)
downloademacs-7d36ad4669e790e53f51aef772f6e62a6860f4c0.tar.gz
emacs-7d36ad4669e790e53f51aef772f6e62a6860f4c0.tar.bz2
emacs-7d36ad4669e790e53f51aef772f6e62a6860f4c0.zip
(smtpmail-via-smtp): Check for servers saying they want AUTH after MAIL FROM, too.
Diffstat (limited to 'lisp/mail/smtpmail.el')
-rw-r--r--lisp/mail/smtpmail.el30
1 files changed, 26 insertions, 4 deletions
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index a860c1ff25f..a08cd7a3fa5 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -470,7 +470,9 @@ The list is in preference order.")
(smtpmail-send-command process string)
(unless (smtpmail-ok-p (setq ret (smtpmail-read-response process))
code)
- (throw 'done (smtpmail-response-text ret)))
+ (throw 'done (format "%s in response to %s"
+ (smtpmail-response-text ret)
+ string)))
ret))
(defun smtpmail-try-auth-methods (process supported-extensions host port
@@ -483,7 +485,9 @@ The list is in preference order.")
(auth-info (car
(auth-source-search :max 1
:host host
- :port (or port "smtp")
+ :port (if port
+ (format "%s" port)
+ "smtp")
:create ask-for-password)))
(user (plist-get auth-info :user))
(password (plist-get auth-info :secret))
@@ -721,9 +725,27 @@ The list is in preference order.")
" BODY=8BITMIME"
"")
"")))
- (smtpmail-command-or-throw
+ (smtpmail-send-command
process (format "MAIL FROM:<%s>%s%s"
- envelope-from size-part body-part)))
+ envelope-from size-part body-part))
+ (cond
+ ((smtpmail-ok-p (setq result (smtpmail-read-response process)))
+ ;; Success.
+ )
+ ((and auth-mechanisms
+ (not ask-for-password)
+ (= (car result) 530))
+ ;; We got a "530 auth required", so we close and try
+ ;; again, this time asking the user for a password.
+ (smtpmail-send-command process "QUIT")
+ (smtpmail-read-response process)
+ (delete-process process)
+ (throw 'done
+ (smtpmail-via-smtp recipient smtpmail-text-buffer t)))
+ (t
+ ;; Return the error code.
+ (throw 'done
+ (smtpmail-response-text result)))))
;; RCPT TO:<recipient>
(let ((n 0))