There are several ways to have Gnus remind you to attach a file if it appears you have not. The following commands search the message content, looking for some words or sentences that may indicate that some attachment should be included. Which words exactly is given by a regular expression.

Here is the default regexp used by thunderbird extension AttachmentReminder:


Try not to send a message without an attachment, first version

  ;; simple regexp used to check the message. Tweak to your own need.
  (defvar my-message-attachment-regexp "\\([Ww]e send\\|[Ii] send\\|attach\\)")
  ;; the function that checks the message
  (defun my-message-check-attachment nil
    "Check if there is an attachment in the message if I claim it."
      (when (search-forward-regexp my-message-attachment-regexp nil t nil)
        (unless (or (search-forward "<#part" nil t nil)
     "No attachment. Send the message ?" nil nil))
  	(error "No message sent")))))
    ;; check is done just before sending the message
    (add-hook 'message-send-hook 'my-message-check-attachment)

Here is another way to check for forgotten attachments. Taken from <>

  (defun check-attachments-attached () 
      (goto-char (point-min)) 
      (let* ( 
             ;; Nil when message came from outside (eg calling emacs as editor) 
             ;; Non-nil marker of end of headers. 
               (concat "^" (regexp-quote mail-header-separator) "$") nil t)) 
             (end-of-headers              ; Start of body. 
               (or internal-messagep 
                   (re-search-forward "^$" nil t) 
              (or (re-search-forward "^-- $" nil t)  
             (old-case-fold-search case-fold-search)) 
              (goto-char end-of-headers) 
              (when (re-search-forward "attach" limit t) 
                (goto-char end-of-headers) 
                ;; the word 'attach' has been used, can we find an 
                ;; attachment? 
                    (or (re-search-forward "^<#/" limit t) 
                         "No attachment. Send the message ? " 
                       (error "no message sent"))))) 
          (set-marker end-of-headers nil)))))  
  (add-hook 'message-send-hook 'check-attachments-attached)