Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Re: Replace, insert or append Bcc header based on Subject field.
       [not found] ` <mailman.8108.1346854652.855.info-gnus-english@gnu.org>
@ 2012-09-11 16:44   ` Abramov Aleksey
  0 siblings, 0 replies; 3+ messages in thread
From: Abramov Aleksey @ 2012-09-11 16:44 UTC (permalink / raw)
  To: info-gnus-english

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Abramov Aleksey <levenson@mmer.org> writes:
>
>> 	((header "Subject" "Ticket#")
>> 	 (bcc (concat
>> 	       (gnus-with-article-buffer
>> 		 (mail-fetch-field "bcc" nil t)) " ,"
>> 	       (bbdb-full-address "support@my.domain.ru"))))))
>> Where is my mistake? Any suggestions are welcome.
>
> Is there really a Bcc header in the article buffer?  That's kinda
> surprising, since the point of the Bcc header is that it's "blind",
> i.e., it's never seen by the recipient.

No, there should be no one bcc header in the original article. Bcc
header have to be set by myself twice. And at the second time it ?have?
to be found by `mail-fetch-field'. 

But in any case, this is my solution to my problem:

#+begin_src emacs-lisp
(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
	(to (with-current-buffer gnus-article-buffer
	      (if (string-match "otrs@otrs.my.domain.ru" (message-fetch-field "from"))
		  "support@my.domain.ru"
		(message-fetch-field "from"))))
	(bcc  (with-current-buffer gnus-article-buffer
		(if (string-match "otrs@otrs.my.domain.ru" (message-fetch-field "from"))
		    "a.abramov@my.domain.ru"
		  (format "%s, %s" "a.abramov@my.domain.ru" "support@my.domain.ru"))))))
#+end_src

-- 
Sincerely,
Abramov Aleksey.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Replace, insert or append Bcc header based on Subject field.
       [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>
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2012-09-05 14:16 UTC (permalink / raw)
  To: Abramov Aleksey; +Cc: info-gnus-english

Abramov Aleksey <levenson@mmer.org> writes:

> 	((header "Subject" "Ticket#")
> 	 (bcc (concat
> 	       (gnus-with-article-buffer
> 		 (mail-fetch-field "bcc" nil t)) " ,"
> 	       (bbdb-full-address "support@my.domain.ru"))))))
> Where is my mistake? Any suggestions are welcome.

Is there really a Bcc header in the article buffer?  That's kinda
surprising, since the point of the Bcc header is that it's "blind",
i.e., it's never seen by the recipient.

-- 
(domestic pets only, the antidote for overdose, milk.)
  http://lars.ingebrigtsen.no  *  Lars Magne Ingebrigtsen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Replace, insert or append Bcc header based on Subject field.
@ 2012-08-19 17:35 Abramov Aleksey
  0 siblings, 0 replies; 3+ messages in thread
From: Abramov Aleksey @ 2012-08-19 17:35 UTC (permalink / raw)
  To: info-gnus-english


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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-11 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.7249.1345398011.855.info-gnus-english@gnu.org>
2012-09-05 14:16 ` Replace, insert or append Bcc header based on Subject field Lars Ingebrigtsen
     [not found] ` <mailman.8108.1346854652.855.info-gnus-english@gnu.org>
2012-09-11 16:44   ` Abramov Aleksey
2012-08-19 17:35 Abramov Aleksey

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).