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 = Mail::SpamAssassin::Client->new({
10 port => 783,
11 host => 'localhost',
12 username => 'someuser'});
13 or
14
15 my $client = Mail::SpamAssassin::Client->new({
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 report
63
64 spam_report
65 public instance (\%) spam_report (String $msg)
66
67 Description: The method implements the report call.
68
69 See the process method for the return value.
70
71 spam_report_ifspam
72 public instance (\%) spam_report_ifspam (String $msg)
73
74 Description: The method implements the report_ifspam call. A report
75 will be returned only if the message is spam.
76
77 See the process method for the return value.
78
79 check
80 public instance (\%) check (String $msg)
81
82 Description: The method implements the check call.
83
84 See the process method for the return value.
85
86 headers
87 public instance (\%) headers (String $msg)
88
89 Description: This method implements the headers call.
90
91 See the process method for the return value.
92
93 learn
94 public instance (Boolean) learn (String $msg, Integer $learntype)
95
96 Description: This method implements the learn call. $learntype should
97 be an integer, 0 for spam, 1 for ham and 2 for forget. The return
98 value is a boolean indicating if the message was learned or not.
99
100 An undef return value indicates that there was an error and you should
101 check the resp_code/resp_msg values to determine what the error was.
102
103 report
104 public instance (Boolean) report (String $msg)
105
106 Description: This method provides the report interface to spamd.
107
108 revoke
109 public instance (Boolean) revoke (String $msg)
110
111 Description: This method provides the revoke interface to spamd.
112
113 ping
114 public instance (Boolean) ping ()
115
116 Description: This method performs a server ping and returns 0 or 1
117 depending on if the server responded correctly.
118
120 _create_connection
121 private instance (IO::Socket) _create_connection ()
122
123 Description: This method sets up a proper IO::Socket connection based
124 on the arguments used when creating the client object.
125
126 On failure, it sets an internal error code and returns undef.
127
128 _parse_response_line
129 private instance (@) _parse_response_line (String $line)
130
131 Description: This method parses the initial response line/header from
132 the server and returns its parts.
133
134 We have this as a separate method in case we ever decide to get fancy
135 with the response line.
136
137 _clear_errors
138 private instance () _clear_errors ()
139
140 Description: This method clears out any current errors.
141
142 _filter
143 private instance (\%) _filter (String $msg, String $command)
144
145 Description: Makes the actual call to the spamd server for the various
146 filter method (ie PROCESS, CHECK, HEADERS, etc). The command that is
147 passed in is sent to the spamd server.
148
149 The return value is a hash reference containing several pieces of
150 information, if available:
151
152 content_length
153
154 isspam
155
156 score
157
158 threshold
159
160 message (if available)
161
162 report (if available)
163
164
165
166perl v5.36.0 2023-01-21 Mail::SpamAssassin::Client(3)