#!/usr/bin/perl # # Copyright (c) 2007 Dominic Hargreaves # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # use strict; use warnings; use MIME::Lite; use Getopt::Long; use Template; # Find our private perl libraries use FindBin; use lib "$FindBin::Bin/../perllib"; use NPEMap; use vars qw($tt_config); use NPEMap::Config; my $dbh = setup_dbh() or die $!; my $set; unless (GetOptions('set=s' => \$set)) { die "Specify either --set scotland or --set northernireland\n"; } die unless ($set eq 'scotland' or $set eq 'northernireland'); my $addresses = $dbh->selectcol_arrayref("SELECT email FROM interest WHERE $set = 't'") or die $!; #print join ', ', @{$addresses}; my $template = Template->new($tt_config); foreach my $address (@${addresses}) { my $message; my $vars = { address => $address }; $template->process('mail_interest.tt', $vars, \$message) or warn $template->error(); my $msg = MIME::Lite->new( From => 'npemap.org.uk ', To => $address, Subject => 'Scottish coverage on npemap.org.uk', Data => $message ); $msg->send or warn "could not send to $address: $!"; } $dbh->disconnect;