:group 'message-sending
:type 'function)
+(defcustom message-default-encoding "7bit"
+ "*Default content transfer encoding type."
+ :group 'message-sending
+ :type 'string)
+
(defcustom message-courtesy-message
"The following message is a courtesy copy of an article\nthat has been posted to %s as well.\n\n"
"*This is inserted at the start of a mailed copy of a posted message.
:group 'message-headers
:type 'boolean)
-(defcustom message-setup-hook nil
+(defcustom message-setup-hook 'turn-on-mime-edit
"Normal hook, run each time a new outgoing message is initialized.
The function `message-setup' runs this hook."
:group 'message-various
:type 'hook)
-(defcustom message-mime-setup-function
- 'turn-on-mime-edit
- "*A function called to set up MIME edit mode."
- :group 'message-various
- :type 'function)
-
(defcustom message-signature-setup-hook nil
"Normal hook, run each time a new outgoing message is initialized.
It is run after the headers have been inserted and before
:group 'message-various
:type 'hook)
-(defcustom message-encode-header-function
+(defcustom message-header-encode-function
'eword-encode-header
- "A function called to after header encode."
+ "A function called to encode header."
:group 'message-various
:type 'function)
-(defcustom message-after-header-encode-hook nil
+(defcustom message-header-encoded-hook nil
"Hook run in a message mode after header encoded. Buffer narrowed
to the headers."
:group 'message-various
(message-generate-headers message-required-mail-headers))
;; Let the user do all of the above.
(run-hooks 'message-header-hook)
- (when (functionp message-encode-header-function)
- (funcall message-encode-header-function))
- (run-hooks 'message-after-header-encode-hook))
- (unwind-protect
- (save-excursion
- (set-buffer tembuf)
- (erase-buffer)
- (insert-buffer message-encoding-buffer)
- ;; Remove some headers.
- (save-restriction
- (message-narrow-to-headers)
+ (when (functionp message-header-encode-function)
+ (funcall message-header-encode-function))
+ (run-hooks 'message-header-encoded-hook))
+ (if (not (message-check-mail-syntax))
+ (progn
+ (message "")
+ ;;(message "Posting not performed")
+ nil)
+ (unwind-protect
+ (save-excursion
+ (set-buffer tembuf)
+ (erase-buffer)
+ (insert-buffer message-encoding-buffer)
;; Remove some headers.
- (message-remove-header message-ignored-mail-headers t))
- (goto-char (point-max))
- ;; require one newline at the end.
- (or (= (preceding-char) ?\n)
- (insert ?\n))
- (when (and news
- (or (message-fetch-field "cc")
- (message-fetch-field "to")))
- (message-insert-courtesy-copy))
- (mime-edit-maybe-split-and-send
- (function
- (lambda ()
- (interactive)
- (funcall message-send-mail-function)
- )))
- (funcall message-send-mail-function))
- (kill-buffer tembuf))
- (set-buffer message-edit-buffer)
- (push 'mail message-sent-message-via)))
+ (save-restriction
+ (message-narrow-to-headers)
+ ;; Remove some headers.
+ (message-remove-header message-ignored-mail-headers t))
+ (goto-char (point-max))
+ ;; require one newline at the end.
+ (or (= (preceding-char) ?\n)
+ (insert ?\n))
+ (when (and news
+ (or (message-fetch-field "cc")
+ (message-fetch-field "to")))
+ (message-insert-courtesy-copy))
+ (mime-edit-maybe-split-and-send
+ (function
+ (lambda ()
+ (interactive)
+ (funcall message-send-mail-function)
+ )))
+ (funcall message-send-mail-function))
+ (kill-buffer tembuf))
+ (set-buffer message-edit-buffer)
+ (push 'mail message-sent-message-via))))
(defun message-send-mail-with-sendmail ()
"Send off the prepared buffer with sendmail."
(message-generate-headers message-required-news-headers)
;; Let the user do all of the above.
(run-hooks 'message-header-hook)
- (when (functionp message-encode-header-function)
- (funcall message-encode-header-function))
- (run-hooks 'message-after-header-encode-hook))
+ (when (functionp message-header-encode-function)
+ (funcall message-header-encode-function))
+ (run-hooks 'message-header-encoded-hook))
(message-cleanup-headers)
(if (not (message-check-news-syntax))
(progn
+ (message "")
;;(message "Posting not performed")
nil)
(unwind-protect
(y-or-n-p
"The article contains control characters. Really post? ")
t))
+ ;; Check content transfer encoding.
+ (message-check 'encoding
+ (message-check-encoding))
;; Check excessive size.
(message-check 'size
(if (> (buffer-size) 60000)
(1- (count-lines (point) (point-max)))))
t)))))
+(defun message-check-mail-syntax ()
+ "Check the syntax of the message."
+ (save-excursion
+ (save-restriction
+ (widen)
+ (and
+ ;; We narrow to the headers and check them first.
+ (save-excursion
+ (save-restriction
+ (message-narrow-to-headers)
+ (message-check-mail-header-syntax)))
+ ;; Check the body.
+ (save-excursion
+ (set-buffer message-edit-buffer)
+ (message-check-mail-body-syntax))))))
+
+(defun message-check-mail-header-syntax ()
+ t)
+
+(defun message-check-mail-body-syntax ()
+ (and
+ ;; Check content transfer encoding.
+ (message-check 'encoding
+ (message-check-encoding)
+ )))
+
+(defun message-check-encoding ()
+ "Check content encoding type."
+ (save-excursion
+ (set-buffer message-encoding-buffer)
+ (message-narrow-to-headers)
+ (let* ((case-fold-search t)
+ (encoding-string
+ (message-fetch-field "content-transfer-encoding"))
+ (encoding (or encoding-string
+ message-default-encoding)))
+ (message "%s %s" encoding-string encoding)
+ (if (not (string-match "^7bit" encoding))
+ t
+ (widen)
+ (set-buffer (get-buffer-create " message syntax"))
+ (erase-buffer)
+ (set-buffer-multibyte nil)
+ (insert-buffer message-encoding-buffer)
+ (goto-char (point-min))
+ (if (re-search-forward "[\200-\377]" nil t)
+ (y-or-n-p
+ "The article contains 8bit characters. Really post? ")
+ t)))))
+
(defun message-checksum ()
"Return a \"checksum\" for the current buffer."
(let ((sum 0))
(push file list)
(message-remove-header "fcc" nil t))
(run-hooks 'message-header-hook)
- (when (functionp message-encode-header-function)
- (funcall message-encode-header-function))
- (run-hooks 'message-after-header-encode-hook))
+ (when (functionp message-header-encode-function)
+ (funcall message-header-encode-function))
+ (run-hooks 'message-header-encoded-hook))
(run-hooks 'message-before-do-fcc-hook)
(goto-char (point-min))
(re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
(run-hooks 'message-header-setup-hook))
(set-buffer-modified-p nil)
(setq buffer-undo-list nil)
- (when (functionp message-mime-setup-function)
- (funcall message-mime-setup-function))
(run-hooks 'message-setup-hook)
(message-position-point)
(undo-boundary))