Function: message-check-recipients
message-check-recipients is an interactive and byte-compiled function
defined in message.el.gz.
Signature
(message-check-recipients)
Documentation
Warn before composing or sending a mail to an invalid address.
This function could be useful in message-setup-hook.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-check-recipients ()
"Warn before composing or sending a mail to an invalid address.
This function could be useful in `message-setup-hook'."
(interactive nil message-mode)
(save-restriction
(message-narrow-to-headers)
(dolist (hdr '("To" "Cc" "Bcc"))
(let ((addr (message-fetch-field hdr)))
(when (stringp addr)
;; First check for syntactically invalid addresses.
(dolist (address (mail-header-parse-addresses addr t))
(unless (mail-header-parse-addresses address)
(unless (y-or-n-p
(format "Email address %s looks invalid; send anyway?"
address))
(user-error "Invalid address %s" address))))
;; Then check for likely-bogus addresses.
(dolist (bog (message-bogus-recipient-p addr))
(and bog
(not (y-or-n-p
(format-message
"Address `%s'%s might be bogus. Continue? "
bog
;; If the encoded version of the email address
;; is different from the unencoded version,
;; then we likely have invisible characters or
;; the like. Display the encoded version,
;; too.
(let ((encoded (rfc2047-encode-string bog)))
(if (string= encoded bog)
""
(format " (%s)" encoded))))))
(user-error "Bogus address"))))))))