If I hit C-c C-c in message-mode (I use notmuch) in order to send an email I've composed, I want to be warned if the Subject: header is empty. E.g. "Really send without Subject? (yes or no)"

When composing new email I fill in the Subject after I have written the body because only then I know exactly what Subject: matches this emails contents best. Sadly I often forget to actually set the Subject and with message-mode the email is sent without Subject:.

I searched online, but I'm astonished that this does not seem to be a recurring topic let alone an already answered FAQ.


One way is to hook into message-send-hook:

message-send-hook is a variable defined in ‘message.el’.
Its value is nil

  This variable may be risky if used as a file-local variable.

Hook run before sending messages.
This hook is run quite early when sending.

For example:

(defun my-confirm-empty-subject ()
  "Allow user to quit when current message subject is empty."
  (or (message-field-value "Subject")
      (yes-or-no-p "Really send without Subject? ")

(add-hook 'message-send-hook #'my-confirm-empty-subject)
  • Great, I tested this and it works. Thanks. – Gregor Apr 23 '18 at 18:05
  • @Gregor Updated to call message-field-value instead of message-fetch-field, which generally worked but could lead to problems. – Basil Apr 25 '18 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.