I may be overthinking this, but here goes.

I am the current developer for a free template based website system used by over 9000 Toastmasters public speaking clubs worldwide. We handle over 300,000 emails in a given week for clubs using our system.

All of our server code is in Perl including our email handler. Our email handler supports a wide variety of forwarding email addresses and distribution lists. Up till recently, our main email security approach was to verify club membership. We still want to do that, but we have added the use of SpamAssassin as an additional step targeted at the provided email addresses that are intended for public use.

I set up SpamAssassin using Mail::SpamAssassin in the email handler, and it basically started dragging the server performance significantly (should have expected that).

I am trying to get the spamc/spamd combo going for us. We have spamd set up. I am just stumbling over setting up the use of spamc in the email handler code.

Current SpamAssassin call from email handler (@ line 479 of email handler--*lots* happening before this):
#Spam Test with SpamAssassin... unless ($SpamChecked || $whitelisted) { my $trigger = $CLUBSITES{'spamthreshold'} || 5.0; my $spamtest = new Mail::SpamAssassin({ 'post_config_text' => "requi +red_score $trigger" }); my $status = $spamtest->check_message_text( $message_received ); if ( $status->is_spam() ) { my $score = $status->get_score(); my $threshold = $status->get_required_score(); my $hits = $status->get_names_of_tests_hit(); my $SpamLogMsg = "Score: $score / $threshold (trigger);\t Positiv +e Tests: $hits"; HandleError("SPAM", $SpamLogMsg, $message_received); } $status->finish(); $spamtest->finish(); $SpamChecked++; }

I need to send $message_received to spamc and capture its output in a variable (preferably) so I can get the spam score. I know I can just back quote a system command to capture stdout to a variable, but how can I do both the stdout and the stdin handling here? This should be simple, but I am just missing it...


In reply to Help with setting up spamc by SteveTheTechie

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.