/[corp_html]/back/newsletter/mail_filter.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /back/newsletter/mail_filter.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Apr 11 14:02:03 2002 UTC (22 years, 1 month ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
news-letter back-end

1 #!/usr/bin/perl -w
2 #
3 # 2002-03-19 Dobrica Pavlinusic <dpavlin@pliva.hr>
4 #
5 # scans e-mail and update PLIVA d.d. newsletter subscribers database
6 # accordingly
7
8 use strict;
9 use DBI;
10
11
12 my $admin = 'newsletter-errors@pliva.hr';
13
14 my $email;
15
16 my $in="";
17
18 while(<>) {
19 $in.=$_;
20 chomp;
21 chomp;
22 if (/confirmation\s+(\S+@\S+)/) {
23 $email = $1;
24 last;
25 }
26 }
27
28 if (! $email) {
29 open(MAIL,"| /usr/lib/sendmail -t") || die "sendmail: $!";
30 print MAIL "To: PLIVA Newsletter admin <$admin>
31 From: PLIVA Newsletter mail filter <newsletter-request\@pliva.hr>
32 Subject: newsletter request unknown mail
33
34 We just received following e-mail which should be newsletter request,
35 but is not recognised by out mail filter:
36
37 $in
38 ";
39 close(MAIL);
40 exit;
41 }
42
43
44 my $dbh = DBI->connect("DBI:Pg:dbname=corp","dpavlin","") || die $DBI::errstr;
45
46 my $sql = "select email,confirmed from news_sub where email = '$email'";
47 my $sth = $dbh->prepare($sql) || die $dbh->errstr();
48 $sth->execute() || die $sth->errstr();
49
50 if (my ($email,$confirmed) = $sth->fetchrow_array() ) {
51 if (! $confirmed) {
52 $dbh->do("update news_sub set confirmed=true where email='$email'");
53 } else {
54 $dbh->do("delete from news_sub where email='$email'");
55 }
56 }

  ViewVC Help
Powered by ViewVC 1.1.26