I don't maintain a database handle throughout the transaction - instead I use the connection object to make notes as the SMTP transaction is completed.
my ( $self, $transaction, $host ) = @_;
# Make sure helo includes a domain
if ( $host !~ /\./ )
$self->log( LOGWARN, "HELO $host doesn't contain a period." );
$transaction->notes( "reject", 1 );
$transaction->notes( "reason", "invalid helo" );
Then I have a series of plugins which do different things at the last step, either forward the message or reject it, but archive a searchable copy for the recipients benefit. Here's a simplified version of the reject + archive plugin:
my ( $self, $transaction ) = @_;
# We only log mails which have been rejected.
if ( 0 == ( $transaction->notes("reject") || 0 ) )
# connect to DB
# archive message
return ( DECLINED, "Rejected this is spam: " . $transaction-Notes
+("reason" ) );
(Actually this is a polite fiction. I actually archive messages to local disk, if they were to be rejected, then later rsync them to a central location - and import them to MySQL there.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||