]> git.eshelyaron.com Git - emacs.git/commitdiff
Try to not put SMTP passwords in the *Messages* buffer
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Oct 2019 20:38:34 +0000 (22:38 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Oct 2019 20:38:44 +0000 (22:38 +0200)
* lisp/mail/smtpmail.el (smtpmail--sanitize-error-message): New
function.
(smtpmail-send-it): Use it.
(smtpmail-send-queued-mail): Ditto.

lisp/mail/smtpmail.el

index 802c9ba788d1f2d1612b9feb38ba74ec426c3b54..9cf28fbe8a5d171298af2e5b214b6de47ecfb2ac 100644 (file)
@@ -354,7 +354,8 @@ for `smtpmail-try-auth-method'.")
                  (when (setq result
                              (smtpmail-via-smtp
                               smtpmail-recipient-address-list tembuf))
-                   (error "Sending failed: %s" result))
+                   (error "Sending failed: %s"
+                           (smtpmail--sanitize-error-message result)))
                (error "Sending failed; no recipients"))
            (let* ((file-data
                    (expand-file-name
@@ -437,13 +438,18 @@ for `smtpmail-try-auth-method'.")
                 (when (setq result (smtpmail-via-smtp
                                    smtpmail-recipient-address-list
                                    (current-buffer)))
-                 (error "Sending failed: %s" result))
+                 (error "Sending failed: %s"
+                         (smtpmail--sanitize-error-message result)))
               (error "Sending failed; no recipients"))))
        (delete-file file-data)
        (delete-file file-elisp)
        (delete-region (point-at-bol) (point-at-bol 2)))
       (write-region (point-min) (point-max) qfile))))
 
+(defun smtpmail--sanitize-error-message (string)
+  "Try to remove passwords and the like from SMTP error messages."
+  (replace-regexp-in-string "\\bAUTH\\b.*" "AUTH" string))
+
 (defun smtpmail-fqdn ()
   (if smtpmail-local-domain
       (concat (system-name) "." smtpmail-local-domain)