Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

e.g.

sub hook_helo { 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" ); } return DECLINED; }

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:

sub hook_queue { my ( $self, $transaction ) = @_; # # We only log mails which have been rejected. # if ( 0 == ( $transaction->notes("reject") || 0 ) ) { return DECLINED; } # connect to DB # archive message # disconnect 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.

Steve
--

In reply to Re^3: Simple (but robust) email server (receiver) by skx
in thread Simple (but robust) email server (receiver) by zby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-24 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found