Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Abramov Aleksey <levenson@mmer.org>
To: info-gnus-english@gnu.org
Subject: Replace, insert or append Bcc header based on Subject field.
Date: Sun, 19 Aug 2012 21:35:34 +0400	[thread overview]
Message-ID: <87a9xqwzrt.fsf@mmer.org> (raw)


Hi everyone. I have problems with `gnus-posting-styles' matching.

Please look what I need to do:

1. I always add Bcc to myself to build a nice threads in my email
account.  

2. We use OTRS system, so there are a lot of mail with Ticket#XXXX, when
I reply on it I'd like to add an additional Bcc header to and send it to
our OTRS system support@my.domain.com email account.

3. OTRS notification comes from another email, I have to replace it
by previously mentioned support@my.domain.com email.

So here is my `gnus-posting-styles'. As it mentioned in manual

,----[ (info "(gnus)Posting Styles") ]
| Each style will be applicable if the first element
| "matches", in some form or other.  The entire alist will be iterated
| over, from the beginning towards the end, and each match will be
| applied, which means that attributes in later styles that match override
| the same attributes in earlier matching styles.  So
`----

So it have to set bcc header for my first group match
"^nnimap\\+aabramov", and after that additional bcc have to be join by
header match. But mail-fetch-field returns nil, and bcc header contains
"nil, .....".

--8<---------------cut here---------------start------------->8---
(defun bbdb-full-address (mail)
  (let ((record (first (bbdb-search  (bbdb-records) nil nil mail))))
    (if (vectorp  record)
	(format "%s <%s>" (bbdb-record-name record)
		(car (bbdb-record-mail record)))
      nil)))

(setq gnus-posting-styles
      '((".*"
	 (name "Abramov Aleksey")
	 (address "levenson@mmer.org")
	 (signature "Sincerely,\nAbramov Aleksey."))
	("^nnimap\\+aabramov"
	 (name "Aleksey Abramov")
	 (address "Aleksey Abramov <a.abramov@my.domain.ru>")
	 (organization "Skytel")
	 (bcc (bbdb-full-address "a.abramov@my.domain.ru"))
	 (signature-file "~/emacs-config/mail-signature.work"))
	("^nnimap\\+localhost"
	 (address "alex@smart.my.domain.ru"))
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
	;; Header replacement
	((header "From" "otrs@otrs.my.domain.ru")
	 (to (bbdb-full-address "support@my.domain.ru")))
	((header "Subject" "Ticket#")
	 (bcc (concat
	       (gnus-with-article-buffer
		 (mail-fetch-field "bcc" nil t)) " ,"
	       (bbdb-full-address "support@my.domain.ru"))))))
--8<---------------cut here---------------end--------------->8---

Where is my mistake? Any suggestions are welcome.

-- 
Sincerely,
Abramov Aleksey.

             reply	other threads:[~2012-08-19 17:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-19 17:35 Abramov Aleksey [this message]
     [not found] <mailman.7249.1345398011.855.info-gnus-english@gnu.org>
2012-09-05 14:16 ` Lars Ingebrigtsen
     [not found] ` <mailman.8108.1346854652.855.info-gnus-english@gnu.org>
2012-09-11 16:44   ` Abramov Aleksey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a9xqwzrt.fsf@mmer.org \
    --to=levenson@mmer.org \
    --cc=info-gnus-english@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).