On Thu, Aug 30 2007, Bernhard Gschaider wrote:
Hi!
I have the following thing I want my Gnus to do, but before I set out
to try it I want to know whether it can be done with juistifyable
effort (my lisp is a bit rusty ....):
I'm receiving mails from a message board software (and a filter sorts
them into a separate folder). Obviously the sender address is that of
the MessageBoard-software. Each mail starts with the message
"This was posted by Isidor Pepranek on Tuesday..."
(the name variies obviously)
Using `nnmail-prepare-incoming-message-hook' should work, I think.
,----[ (info "(gnus)Washing Mail") ]
| `nnmail-prepare-incoming-message-hook'
| This hook is called narrowed to each message.
`----
Untested (and a little ugly):
(defun rs-nnmail-fetch-sender-from-body ()
"Fetch sender's name from body and isert it into the From: header."
(save-excursion
(let ((case-fold-search t)
endofheaders
name)
(goto-char (point-min))
(search-forward "\n\n" nil t)
(setq endofheaders (1- (point)))
(re-search-forward "^This was posted by \\(.*\\) on [MTWFS]" nil t)
(setq name (match-string 1))
(goto-char endofheaders)
(beginning-of-line)
(insert
(format "From: %s <via-MessageBoard@YourCompany.invalid>\n" name))
(goto-char (point-min))
(re-search-forward "^From: ")
(beginning-of-line)
(insert "Old-"))))
(add-hook 'nnmail-prepare-incoming-message-hook
'rs-nnmail-fetch-sender-from-body)