Thank you David. Excerpts from David J. Hamilton's message of Thu Mar 03 12:35:20 -0500 2011: > Excerpts from Philippe LeCavalier's message of Thu Mar 03 05:26:03 -0800 2011: > > From: Philippe LeCavalier <[email protected]> > > To: sup-talk <[email protected]> > > Cc: > > Bcc: > > Subject: hook with external file ref > > > > addressfile = File.open("/home/user/path/addressfile","r") > > if ! addressfile.grep(/#{message.from.email}/).empty? > > message.add_label :somelabel > > end > > > > In the wiki it states "which contains one e-mail address per line". I'm just > > wondering what I would have to change in the code in order to list just the > > domain. > > It's a bit tricky because you're trying to find the email address in the > address file, rather than match one of many patterns in the address file to > the > email. If you use the latter approach you should be able to put whatever > patterns you want, including just the domain. > > patterns = File.readlines "/path/to/my/addressfile" > patterns.each do |pattern| > if message.from.email =~ /#{pattern}/ > message.add_label :somelabel > end > end > > If you take this approach then you should be able to have lines in your > addressfile like ‘foo.com’ (sans quotes). This will actually match a little > more than what you probably intend (e.g. it would match emails from > [email protected] or even [email protected]), but is likely good enough and saves > you from having to learn regular expressions.
I'll give this a try and see what the outcome is. -- Thanks, Phil _______________________________________________ sup-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/sup-talk
