source: trunk/npemap.org.uk/scripts/mail_interest @ 516

Last change on this file since 516 was 516, checked in by Dominic Hargreaves, 13 years ago

Add spamming script

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2#
3# Copyright (c) 2007 Dominic Hargreaves
4# See accompanying file "LICENCE" for licence details
5
6use strict;
7use warnings;
8
9use MIME::Lite;
10use Getopt::Long;
11use Template;
12
13# Find our private perl libraries
14use FindBin;
15use lib "$FindBin::Bin/../perllib";
16use NPEMap;
17use vars qw($tt_config);
18use NPEMap::Config;
19
20my $dbh = setup_dbh() or die $!;
21
22my $set;
23unless (GetOptions('set=s' => \$set)) {
24    die "Specify either --set scotland or --set northernireland\n";
25}
26
27die unless ($set eq 'scotland' or $set eq 'northernireland');
28
29my $addresses = $dbh->selectcol_arrayref("SELECT email FROM interest WHERE $set = 't'") or die $!;
30
31#print join ', ', @{$addresses};
32
33my $template = Template->new($tt_config);
34
35foreach my $address (@${addresses}) {
36    my $message;
37    my $vars = { 
38        address => $address
39    };
40
41    $template->process('mail_interest.tt', $vars, \$message)
42        or warn $template->error();
43
44    my $msg = MIME::Lite->new(
45        From => 'npemap.org.uk <webmaster@npemap.org.uk>',
46        To => $address,
47        Subject => 'Scottish coverage on npemap.org.uk',
48        Data => $message
49    );
50
51    $msg->send or warn "could not send to $address: $!";
52}
53
54$dbh->disconnect;
Note: See TracBrowser for help on using the repository browser.