#! /usr/bin/perl -w use strict; use File::Spec; use Mail::MboxParser; use DBI; my $dbh = DBI->connect('DBI:mysql:blessing:webadept.net', 'yourusername', 'yourpassword', undef); chdir("/var/spool/mail"); my $mail = File::Spec->catfile('blessing'); my $mb = Mail::MboxParser->new($mail); my @a = $mb->get_messages; my $mailbox = 'blessing'; open(IN,">$mailbox"); close(IN); foreach my $msg(@a) {< my $subject = $msg->header->{subject}; my $from = $msg->header->{from}; my $body = $msg->body->as_string; $body=$dbh->quote($body); $from=$dbh->quote($from); $subject = $dbh->quote($subject); my $q = qq`insert into blessings values( '', $subject, $body, current_date, $from, 1, '') `; my $sth2 = $dbh->prepare($q); $sth2->execute() || die "Failed on update : \n$q\n\n"; } #foreach message loop ends $dbh->disconnect;