aboutsummaryrefslogtreecommitdiffstats
path: root/bin/test-mailin
blob: 33f8ab80cec3f4cbcc2d8788d0da6cc1bbfc6727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl -w -I../../perllib
#
# test-mailin:
# Receives incoming mail for the test harness, and stores it in the database
# for the test harness to access.
# 
# Hook this up with something like this in /etc/aliases...
#   pbharness: "| /home/francis/devel/mysociety/pb/bin/test-mailin"
# ... or some other appropriate way.
#
# Copyright (c) 2005 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#

# Horrible boilerplate to set up appropriate library paths.
use FindBin;
use lib "$FindBin::Bin/../perllib";
use lib "$FindBin::Bin/../../perllib";
chdir $FindBin::Bin;

use File::Slurp;

use mySociety::SystemMisc qw(print_log);
mySociety::SystemMisc::log_to_stderr(0);

use mySociety::Config;
mySociety::Config::set_file('../conf/general');
use mySociety::WebTestHarness;

print_log('notice', "started");
our $wth = new mySociety::WebTestHarness();
$wth->database_connect('BCI_');
print_log('notice', "reading mail from STDIN");
my $slurped = read_file(\*STDIN);
print_log('notice', "calling email_incoming");
$wth->email_incoming($slurped);
print_log('notice', "done");