1Mail::SpamAssassin::CliUesnetr(3C)ontributed Perl DocumeMnatialt:i:oSnpamAssassin::Client(3)
2
3
4
6 Mail::SpamAssassin::Client - Client for spamd Protocol
7
8 NOTE: This interface is alpha at best, and almost guaranteed to change
9
11 my $client = new Mail::SpamAssassin::Client({port => 783,
12 host => 'localhost',
13 username => 'someuser'});
14
15 if ($client->ping()) {
16 print "Ping is ok\n";
17 }
18
19 my $result = $client->process($testmsg);
20
21 if ($result->{isspam} eq 'True') {
22 do something with spam message here
23 }
24
26 Mail::SpamAssassin::Client is a module that provides a perl implementa‐
27 tion for the spamd protocol.
28
30 new
31
32 public class (Mail::SpamAssassin::Client) new (\% $args)
33
34 Description: This method creates a new Mail::SpamAssassin::Client
35 object.
36
37 process
38
39 public instance (\%) process (String $msg, Boolean $is_check_p)
40
41 Description: This method makes a call to the spamd server and depending
42 on the value of $is_check_p either calls PROCESS or CHECK.
43
44 The return value is a hash reference containing several pieces of
45 information, if available:
46
47 content_length
48
49 isspam
50
51 score
52
53 threshold
54
55 message
56
57 check
58
59 public instance (\%) check (String $msg)
60
61 Description: The method implements the check call.
62
63 Since check and process are so similar, we simply pass this call along
64 to the process method with a flag to indicate to actually make the
65 CHECK call.
66
67 See the process method for the return value.
68
69 learn
70
71 public instance (Boolean) learn (String $msg, Integer $learntype)
72
73 Description: This method implements the learn call. $learntype should
74 be an integer, 0 for spam, 1 for ham and 2 for forget. The return
75 value is a boolean indicating if the message was learned or not.
76
77 An undef return value indicates that there was an error and you should
78 check the resp_code/resp_msg values to determine what the error was.
79
80 report
81
82 public instance (Boolean) report (String $msg)
83
84 Description: This method provides the report interface to spamd.
85
86 revoke
87
88 public instance (Boolean) revoke (String $msg)
89
90 Description: This method provides the revoke interface to spamd.
91
92 ping
93
94 public instance (Boolean) ping ()
95
96 Description: This method performs a server ping and returns 0 or 1
97 depending on if the server responded correctly.
98
100 _create_connection
101
102 private instance (IO::Socket) _create_connection ()
103
104 Description: This method sets up a proper IO::Socket connection based
105 on the arguments used when greating the client object.
106
107 On failure, it sets an internal error code and returns undef.
108
109 _parse_response_line
110
111 private instance (@) _parse_response_line (String $line)
112
113 Description: This method parses the initial response line/header from
114 the server and returns its parts.
115
116 We have this as a seperate method in case we ever decide to get fancy
117 with the response line.
118
119 _clear_errors
120
121 private instance () _clear_errors ()
122
123 Description: This method clears out any current errors.
124
125
126
127perl v5.8.8 2008-01-05 Mail::SpamAssassin::Client(3)