;; Make sure the Message-ID header is present in newly created messages
(setq message-generate-headers-first '(Message-ID))
;; Prevent emacs from resetting the Message-ID before the message is sent.
(setq message-deletable-headers
(remove 'Message-ID message-deletable-headers))
(setq gnus-posting-styles
'(("^pl\\.test$"
("Reply-To" '(message-make-reply-to)))))
Note the additional quote and parentheses around message-make-reply-to
. The explanation for this is that the function is run at different times, depending on whether it's given as a symbol or as a quoted s-expression.
- If given as symbol, it is run when a lambda function is added to
message-setup-hook
. That happens in a message-mode-hook
, i.e. right after the new buffer is created and switched into message-mode
. The cause for this is some wild quoting/unquoting of values during creation of the lambda function.
- If given as a quoted sexpr, evaluation is delayed until after the buffer is filled with initial values. It is close to the last code which is run on message setup.
Alternative Solution (without gnus-posting-styles
)
In cases where the new header should be added to every new message, the Reply-To
header can also be set using the message-header-setup-hook
. A custom hook needs to be defined to add the header for each new message.
(defun reply-to-message-header-setup-hook ()
(let* ((msg-id (message-fetch-field "Message-ID"))
(reply-to (my-script ".../reply-to-pl" msg-id)))
(message-add-header (concat "Reply-To: " reply-to))))
;; Call the hook every time a new message is created
(add-hook 'message-header-setup-hook 'reply-to-message-header-setup-hook)
;; Make sure the Message-ID header is present in newly created messages
(setq message-generate-headers-first '(Message-ID))
(message-fetch-field "Message-Id")
, generating the Reply-To field could be done by usingmessage-goto-reply-to
and then messing around with the line content or by(message-replace-header "Reply-To" "my value")
. – Extravasatedefun my-script(path &optional param) ...
. The dollowing in lisp function used to generated X-Reply-To have not passed Message-Id: to the script (my-script ".../script" (message-fetch-field "Message-Id")) – Rectorymessage-generate-headers-first
, cg. the relevant message documentation – Extravasate'(message-generate-headers-first t)
have not fixed "unset script param" problem. Message-Id is on both message-required-news-headers and message-required-mail-headers. P.S. I use custom lisp function to generate Message-Id. – Rectorymessage-make-message-id
lisp function to generate message-id – Rectory