=pod
=head1 SUMMARY
use Mail::Audit qw (Weblog)
my $mail = Mail::Audit->new();
# use Mail::Audit to figure out
# if we're interested in the message
# here...
$mail->post();
# ?
$mail->accept();
return 1;
=cut
package Mail::Audit::Weblog;
use Mail::Audit;
return 1;
package Mail::Audit;
# Maybe Net::Weblog::CommonAPI ?
use Net::Weblog;
sub post {
my $self = shift;
$self->tidy();
my $weblog = Net::Weblog->new(...);
my $post = $weblog->new_post();
$post->title($self->subject());
$post->author($weblog->from());
$post->body(@{$self->body()});
$post->footnote($self->header());
$post->category("unread");
# Use power of Mail::Audit ($self)
# to assign additional categories
# here...
# ?
$post->publish();
# For sheer laziness, we could also
# use Mail::XML and a write a SAX::Filter
# for handing off to a $weblog->raw (?)
# method. So, if we were using $self to
# auto-generate categories we would also
# do $self->put(category1,$category) before
# doing :
my $xml = "";
my $writer = XML::SAX::Writer->new(Output=>\$xml);
my $filter = Net::Weblog::Filter::MailToBlog->new(Handler=>$writer);
my $parser = XML::SAX::ParseFactory->parser(Handler=>$filter);
# Not actually sure Mail::Audit can do this
$parser->parse_string($self->to_xml());
# raw ??? Anyway, if you were into that sort of
# thing you could forget about creating a $weblog
# object altogether (not to mention $writer and $xml)
# and just pass your blog credentials to the $filter
# object and have it post the message when it
# encountered the end_document event...
$weblog->raw($xml);
# Which doesn't look so lazy anymore...
# The upshot, of course, is that you could bundle
# the above and use the code outside of your mail
# filter.
return 1;
}
return 1;
see also :
hurl