From 74a1fe5718ff4cec0f04c32a8cb0cd356aa8d6d7 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 7 Nov 2001 18:05:02 +0000 Subject: mail-to-sql.php: - rewrote the script in PHP. - added support for mailing list. - made the parser better. --- scripts/mail-to-sql.pl | 53 -------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 scripts/mail-to-sql.pl (limited to 'scripts/mail-to-sql.pl') diff --git a/scripts/mail-to-sql.pl b/scripts/mail-to-sql.pl deleted file mode 100644 index 6fcb89631..000000000 --- a/scripts/mail-to-sql.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -w - -use DBI; - -# Database settings: -my $db_name = 'drop'; -my $db_user = 'drop'; -my $db_pass = 'drop'; - -# Read data from stdin: -my @data = ; -my $data = join '', @data; - -my @chunks = split(/\n\n/, $data); - -# Parse the header into an associative array: -foreach $line (split(/\n/, $chunks[0])) { - # The field-body can be split into a multiple-line representation, - # which is called "folding". According to RFC 822, the rule is that - # wherever there may be linear-white-space (not simply LWSP-chars), - # a CRLF immediately followed by at least one LWSP-char may instead - # be inserted. - - if ($line =~ /^\s(.*?)/) { - $data = $1; - } - elsif ($line =~ /(.*?):\s(.*)/) { - $key = lc($1); - $data = $2; - } - - if ($key && $data) { - $header{$key} .= $data; - } -} - -# Debug output: - # foreach $key (sort keys %header) { - # print "$key: $header{$key}\n--------\n"; - # } - -# Store the complete header into a field: -$header{header} = $chunks[0]; -$chunks[0] = ""; - -# Construct the mail body: -foreach $line (@chunks) { - $body .= "$line\n\n"; -} - -my $db = DBI->connect("DBI:mysql:$db_name", "$db_user", "$db_pass") or die "Couldn't connect recepient database: " . DBI->errstr; -$db->do("INSERT INTO mail (subject, header_from, header_to, header_cc, header_reply_to, header, body, timestamp) VALUES (". $db->quote($header{"subject"}) .", ". $db->quote($header{"from"}) .", ". $db->quote($header{"to"}) .", ". $db->quote($header{"cc"}) .", ". $db->quote($header{"reply-to"}) .", ". $db->quote($header{"header"}) .", ". $db->quote($body) .", ". $db->quote(time()) .")") or die "Couldn't execute query: " . $db->errstr; -$db->disconnect(); -- cgit v1.2.3