Steve Goldman
2009-Jul-23 01:10 UTC
[sup-talk] Choose "From:" address based on message content?
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
Steve Goldman
2009-Jul-23 02:51 UTC
[sup-talk] Choose "From:" address based on message content?
Excerpts from Steve Goldman''s message of Wed Jul 22 21:10:41 -0400 2009:> > 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. >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 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
William Morgan
2009-Jul-27 16:52 UTC
[sup-talk] Choose "From:" address based on message content?
Reformatted excerpts from Steve Goldman''s message of 2009-07-22:> Can sup do it?Shit yes. These insane requests are exactly why I am favoring hooks over configuration. -- William <wmorgan-sup at masanjin.net>
William Morgan
2009-Jul-27 16:53 UTC
[sup-talk] Choose "From:" address based on message content?
Reformatted excerpts from Steve Goldman''s message of 2009-07-22:> require ''eregex'' > > r = Regexp.new(''word'', Regexp::IGNORECASE); > if header.to_s.grep(r).size > 0 or body.to_s.grep(r).size > 0You 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>