help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: prevent Emacs from sending mail with no subject


From: Kevin Rodgers
Subject: Re: Q: prevent Emacs from sending mail with no subject
Date: Tue, 23 Dec 2003 11:51:28 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Eric Pement wrote:

I would like to know how to prevent Emacs from sending email with no
subject (or with a subject line that contains only whitespace). I've
accidentally sent a couple of messages this way, and I think Emacs
converted the subject line to "(unknown)" for me, but I'm not sure. At
any rate, I want Emacs to not send the message if the subject line is
empty, but to prompt me to enter the missing subject.

I've already checked the FAQ, the Customization menu, "Learning GNU
Emacs" and searched the Google archives for this issue, but I can't
seem to find the answer. Any help would be appreciated.

Emacs is not changing your Subject header (I just checked the lisp/mail/*.el
files distributed with Emacs 21.3).  It is probably your site's MTA -- are
you using sendmail.el or smtpmail.el, or something else?

In any case, you probably want to add the check for an empty Subject header
to mail-send-hook:

(defun mail-send-check-subject ()
  (save-excursion
    ;; see mail-position-on-field:
    (goto-char (point-min))
    (let ((case-fold-search t))
      (if (re-search-forward "^Subject:[ \t]*" (mail-header-end))
          ;; else signal an error
          (if (eolp)
              (insert (read-string "Subject: ")))))))

(add-hook 'mail-send-hook 'mail-send-check-subject)

--
Kevin Rodgers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]