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

Net::SMTP, response from server

by imcsk8 (Pilgrim)
on Nov 18, 2004 at 17:41 UTC ( [id://408825]=perlquestion: print w/replies, xml ) Need Help??

imcsk8 has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

i have a spam filter on my postfix server, and i'm using Net::SMTP to redirect my spam filtered mail to the anti virus server, which in turn sends the mail to my mailbox server. It kind of works allright, but (the omnipresent but) sometimes i get a error redirecting the mail and i need to know if Net::SMTP can give me the error string that the anti virus server is issuing, i have read the perldoc of Net::SMTP and Net::Cmd but there's no method in this documents that refers to the response of the server (or i could just missed something), the closest method to that is the message method but it alwas returns "Invalid command order" so i don't think this is the method i'm looking for.
the code i'm using is this:

$smtp->mail($ARGV[1]); $smtp->recipient(@to); if(!$smtp->data($sal.".\r\n")){ print STDERR "Error enviando datos (".$smtp->message.") !!!\n" +; $smtp->quit(); exit($EX_TEMPFAIL); } $smtp->quit(); exit;

i really appreciate help on this since i can't debug my program and i'm having a very high volume of error messages.

thanks



ignorance, the plague is everywhere
--guttermouth

Replies are listed 'Best First'.
Re: Net::SMTP, response from server
by cfreak (Chaplain) on Nov 19, 2004 at 01:17 UTC

    You may have a reason for reinventing the wheel, but if you don't, I suggest using Amavis-New. It connects with Spam-Assassin and whatever virus scanner you configure (I use ClamAV). Its very easy to use and very reliable (I use it to scan incoming mail for about 200 domains). It works great with Postfix and its written in Perl which just makes it even better :).

    If you use it I'd also suggest uninstalling your vendor's Spam-Assassin if you have one and install the one from CPAN. (At least with Fedora they hadn't updated to SA 3 yet which is a lot better).

    Feel free to PM me if you'd like some more info

    HTH

      thank you, a friend of mine recommended amavisd-new to me so i'm installing it right now.

      the reason i tried a self made filter first was to understand how the postfix filters work, learn more about ipc and check the behaviour of the server before moving to a more robust solution

      thanks for the help


      ignorance, the plague is everywhere
      --guttermouth
Re: Net::SMTP, response from server
by nimdokk (Vicar) on Nov 18, 2004 at 19:03 UTC
    Have you tried turning debugging on to see what the responses are?

    my $smtp=Net::SMTP->new('mailserver', Debug => 1);
      i can se the debugging on the postfix log file, but it's truncated, does Net::SMTP send the debug texto to STDERR??

      UPDATE:

      i redirected STDERR (yes, the debug output goes to STDERR) to a file and i found that the mail server was returning errors but it didn't close the connection until the DATA command was issued, then it returns the "Invalid command order" error and close the connection (in fact in all the cases the first error issued was an invalid mailbox error)

      <br ignorance, the plague is everywhere
      --guttermouth

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://408825]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found