[Mail] Move SMTP error handling code directly to ‘db/smtpmail-send-it’
This commit is contained in:
parent
0d81c7fa0b
commit
b8912ae08d
12
init.el
12
init.el
@ -1591,17 +1591,7 @@
|
|||||||
:defer t
|
:defer t
|
||||||
:init (setq smtpmail-stream-type 'starttls
|
:init (setq smtpmail-stream-type 'starttls
|
||||||
smtpmail-smtp-service 587
|
smtpmail-smtp-service 587
|
||||||
smtpmail-debug-info t)
|
smtpmail-debug-info t))
|
||||||
:config (progn
|
|
||||||
;; Show trace buffer when something goes wrong
|
|
||||||
(defadvice smtpmail-send-it (around display-trace-buffer disable)
|
|
||||||
"If an error is signalled, display the process buffer."
|
|
||||||
(condition-case signals-data
|
|
||||||
ad-do-it
|
|
||||||
(error (shrink-window-if-larger-than-buffer
|
|
||||||
(display-buffer (get-buffer (format "*trace of SMTP session to %s*"
|
|
||||||
smtpmail-smtp-server))))
|
|
||||||
(signal (car signals-data) (cdr signals-data)))))))
|
|
||||||
|
|
||||||
(setq starttls-use-gnutls t
|
(setq starttls-use-gnutls t
|
||||||
starttls-extra-arguments '("--strict-tofu"))
|
starttls-extra-arguments '("--strict-tofu"))
|
||||||
|
|||||||
@ -117,7 +117,11 @@ will also be recognized when sending mail."
|
|||||||
|
|
||||||
(defun db/smtpmail-send-it ()
|
(defun db/smtpmail-send-it ()
|
||||||
"Send prepared message in current buffer.
|
"Send prepared message in current buffer.
|
||||||
This function uses `message-smtpmail-send-it’, but sets `smtpmail-smtp-server’, `smtpmail-stream-type’, `smtpmail-smtp-service’, and `smtpmail-smtp-user’ based on the entry of the \"From: \" header and the value of `db/mail-accounts’."
|
This function uses `message-smtpmail-send-it’, but sets
|
||||||
|
`smtpmail-smtp-server’, `smtpmail-stream-type’,
|
||||||
|
`smtpmail-smtp-service’, and `smtpmail-smtp-user’ based on the
|
||||||
|
entry of the \"From: \" header and the value of
|
||||||
|
`db/mail-accounts’."
|
||||||
(let* ((from (or (save-restriction
|
(let* ((from (or (save-restriction
|
||||||
(message-narrow-to-headers)
|
(message-narrow-to-headers)
|
||||||
(mail-fetch-field "From"))
|
(mail-fetch-field "From"))
|
||||||
@ -125,6 +129,7 @@ This function uses `message-smtpmail-send-it’, but sets `smtpmail-smtp-server
|
|||||||
(address (cadr (mail-extract-address-components from)))
|
(address (cadr (mail-extract-address-components from)))
|
||||||
(account (assoc address db/mail-accounts)))
|
(account (assoc address db/mail-accounts)))
|
||||||
(message "Using address: %s" address)
|
(message "Using address: %s" address)
|
||||||
|
(condition-case signal-data
|
||||||
(if account
|
(if account
|
||||||
(progn
|
(progn
|
||||||
(message "Sending with account for %s" address)
|
(message "Sending with account for %s" address)
|
||||||
@ -143,7 +148,12 @@ This function uses `message-smtpmail-send-it’, but sets `smtpmail-smtp-server
|
|||||||
(message-smtpmail-send-it)))
|
(message-smtpmail-send-it)))
|
||||||
(if (yes-or-no-p "Sending with default account settings?")
|
(if (yes-or-no-p "Sending with default account settings?")
|
||||||
(message-smtpmail-send-it)
|
(message-smtpmail-send-it)
|
||||||
(message "Sending aborted as requested by user.")))))
|
(message "Sending aborted as requested by user.")))
|
||||||
|
;; in case of error, display the SMTP trace buffer
|
||||||
|
(error (shrink-window-if-larger-than-buffer
|
||||||
|
(display-buffer (get-buffer (format "*trace of SMTP session to %s*"
|
||||||
|
smtpmail-smtp-server))))
|
||||||
|
(signal (car signal-data) (cdr signal-data))))))
|
||||||
|
|
||||||
|
|
||||||
;; Setting other Gnus accounts
|
;; Setting other Gnus accounts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user