Subject: [sup-talk] Choose "From:" address based on message content?

From: [email-masked] (Steve Goldman)
Date: Wed, 22 Jul 2009 21:10:41 -0400

Here's what I want:

After I compose an email (new or a reply), I want sup to grep the
entire message (recipients, subject, body, etc.) for a single word and
choose address A if that word is there and address B otherwise.

Can sup do it?

Thanks.

-- 

Steve Goldman
sgoldman at tower-research.com

T: 212.219.6014
F: 212.219.6007

Tower Research Capital, LLC
377 Broadway, 11th Fl.
New York, NY 10013

---

From: [email-masked] (Steve Goldman)
Date: Wed, 22 Jul 2009 22:51:54 -0400

> choose address A if that word is there and address B otherwise.

I think I answered my own question.

I added an "after-edit" hook call in edit-message-mode.rb and wrote a
hook that looks like this:

require 'eregex'

r = Regexp.new('word', Regexp::IGNORECASE);
if header.to_s.grep(r).size > 0 or body.to_s.grep(r).size > 0
  header["From"] = "Steve Goldman <sgoldman at other-address.com>"
end
-- 

Steve Goldman

T: 212.219.6014
F: 212.219.6007

---

From: [email-masked] (William Morgan)
Date: Mon, 27 Jul 2009 09:52:02 -0700

> Can sup do it?

Shit yes. These insane requests are exactly why I am favoring hooks over
configuration.
-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (William Morgan)
Date: Mon, 27 Jul 2009 09:53:58 -0700

> if header.to_s.grep(r).size > 0 or body.to_s.grep(r).size > 0

You can just use body.to_s =~ /word/i || header.join =~ /i/. No need for
all the fancy libraries and method calls.
-- 
William <wmorgan-sup at masanjin.net>