1Mail::SpamAssassin::CliUesnetr(3C)ontributed Perl DocumeMnatialt:i:oSnpamAssassin::Client(3)
2
3
4
6 Mail::SpamAssassin::Client - Client for spamd Protocol
7
9 my $client = new Mail::SpamAssassin::Client({
10 port => 783,
11 host => 'localhost',
12 username => 'someuser'});
13 or
14
15 my $client = new Mail::SpamAssassin::Client({
16 socketpath => '/path/to/socket',
17 username => 'someuser'});
18
19 Optionally takes timeout, which is applied to IO::Socket for the
20 initial connection. If not supplied, it defaults to 30 seconds.
21
22 if ($client->ping()) {
23 print "Ping is ok\n";
24 }
25
26 my $result = $client->process($testmsg);
27
28 if ($result->{isspam} eq 'True') {
29 do something with spam message here
30 }
31
33 Mail::SpamAssassin::Client is a module which provides a perl
34 implementation of the spamd protocol.
35
37 new
38 public class (Mail::SpamAssassin::Client) new (\% $args)
39
40 Description: This method creates a new Mail::SpamAssassin::Client
41 object.
42
43 process
44 public instance (\%) process (String $msg)
45
46 Description: This method calls the spamd server with the PROCESS
47 command.
48
49 The return value is a hash reference containing several pieces of
50 information, if available:
51
52 content_length
53
54 isspam
55
56 score
57
58 threshold
59
60 message
61
62 check
63 public instance (\%) check (String $msg)
64
65 Description: The method implements the check call.
66
67 See the process method for the return value.
68
69 headers
70 public instance (\%) headers (String $msg)
71
72 Description: This method implements the headers call.
73
74 See the process method for the return value.
75
76 learn
77 public instance (Boolean) learn (String $msg, Integer $learntype)
78
79 Description: This method implements the learn call. $learntype should
80 be an integer, 0 for spam, 1 for ham and 2 for forget. The return
81 value is a boolean indicating if the message was learned or not.
82
83 An undef return value indicates that there was an error and you should
84 check the resp_code/resp_msg values to determine what the error was.
85
86 report
87 public instance (Boolean) report (String $msg)
88
89 Description: This method provides the report interface to spamd.
90
91 revoke
92 public instance (Boolean) revoke (String $msg)
93
94 Description: This method provides the revoke interface to spamd.
95
96 ping
97 public instance (Boolean) ping ()
98
99 Description: This method performs a server ping and returns 0 or 1
100 depending on if the server responded correctly.
101
103 _create_connection
104 private instance (IO::Socket) _create_connection ()
105
106 Description: This method sets up a proper IO::Socket connection based
107 on the arguments used when creating the client object.
108
109 On failure, it sets an internal error code and returns undef.
110
111 _parse_response_line
112 private instance (@) _parse_response_line (String $line)
113
114 Description: This method parses the initial response line/header from
115 the server and returns its parts.
116
117 We have this as a separate method in case we ever decide to get fancy
118 with the response line.
119
120 _clear_errors
121 private instance () _clear_errors ()
122
123 Description: This method clears out any current errors.
124
125 _filter
126 private instance (\%) _filter (String $msg, String $command)
127
128 Description: Makes the actual call to the spamd server for the various
129 filter method (ie PROCESS, CHECK, HEADERS, etc). The command that is
130 passed in is sent to the spamd server.
131
132 The return value is a hash reference containing several pieces of
133 information, if available:
134
135 content_length
136
137 isspam
138
139 score
140
141 threshold
142
143 message (if available)
144
145
146
147perl v5.12.4 2011-06-06 Mail::SpamAssassin::Client(3)