Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > email parsing->mysql:: Can someone explain me this perl script?

Thread Tools

email parsing->mysql:: Can someone explain me this perl script?

Posts: n/a
I am a perl noob that can learn if you give me a hand.
I currently need a script to read emails using email piping,
extract some information and put it inside a MySQL database.

The reason? Make some statistics of my email server antivirus.

The sample body of my emails is as follows:

-----------------> Source of Sample email source <---------

From: "MailScanner" <(E-Mail Removed)>
To: Removed)
Subject: Advertencia: Virus detectado en e-mail
Message-Id: <(E-Mail Removed)>
Date: Sun, 29 Aug 2004 17:33:08 -0500
Se han encontrado virus en el siguiente e-mail:
Sender: (E-Mail Removed)
IP Address:
Recipient: (E-Mail Removed)
MessageID: 1C1YEL-0002Zn-VA
Informe: contains Worm.Mydoom.M
-----------------> Source of Sample email source <---------

For this purpose I got this script (called amavistat), however
I need that someone tells me what modifications should I do to
to make it work in my case, here I am attaching the source of
the script

# Veghead 2001
# Fixed stupid '=' vs 'eq' bug - Veghead 2003-08-14
# changes 18.08.03 - Marcus Schopen <(E-Mail Removed)>

use DBD::mysql;

$dbh=DBI->connect("DBI:mysql:$dbname:$server",$username,$pa ssword) or
die("Can't connect to MySQL");


while(<>) {
if ($state eq "inheader") {
if (length($_)<2) {$state="inbody";}
elsif ($_=~/^Subject: VIRUS FROM <(.*)> \((.*)\)/) {
} elsif ($state="inbody") {
if ($_=~/^-> <([^\@]+\@[^\@]+)>/) {
if ($viruswarn) {do_something();}

sub do_something {
foreach $vname ($viruses) {
print "From: $virusfrom\nTo: $virusto\nVirus: $vname\n\n";
$sth = $dbh->prepare("insert into $table values
Reply With Quote
Tad McClellan
Posts: n/a
albatroz <(E-Mail Removed)> wrote:

> For this purpose I got this script (called amavistat), however
> I need that someone

> # Veghead 2001
> # changes 18.08.03 - Marcus Schopen <(E-Mail Removed)>

Ask Veghead or Marcus, it is their (amateurish looking) program.

If they won't help, then you will need to learn some Perl
before you will be able to modify the Perl program.

What part of the program you posted are you having trouble figuring out?

If you tell us where you are stuck, we can probably help unstick you.

If you don't understand any of the parts, then go off and learn
Perl until you do, then come back here with any remaining questions.

Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
70-292: can someone please verify / explain the answer to this question Tim Moor MCSE 7 12-18-2005 03:30 AM
Someone can explain this to me? Tosh Cisco 4 11-19-2005 03:48 PM
Can someone explain this route-map command Cisco 8 02-04-2005 12:35 PM
Can someone explain this? Ray Microsoft Certification 1 09-01-2003 02:12 AM
Can someone explain MergableProperty to me? Ian ASP .Net 0 06-24-2003 10:37 PM