0

I am using a basic PHP class to run the SpamAssassin Network Protocol commands on a remote server. I installed SpamAssassin following a guide, just skipping the PostFix part.

No matter what command I run (CHECK, REPORT, PING, etc), I only get a blank or empty response.

Here is a basic example of a PING that should return, per the manual: SPAMD/1.5 0 PONG\r\n. Instead, it's an empty response.

$socket = fsockopen($hostname = 'my-remote-server-ip', $port = 783, $errno, $errstr);
fwrite($socket, "PING SPAMC/1.5\r\n");
$response = fread($socket,99999);
die("<pre>" . print_r($response,1) . "</pre>");

Am I doing something wrong with my writing/reading? What settings should I be checking on my remote server?

Luke Shaheen
  • 4,262
  • 12
  • 52
  • 82

1 Answers1

0

Turns out my remote connection was being refused. I figured this out by running spamd -D -i my.remote.ip -p 783, which actively shows you the debugging information for spamd.

This log showed me warn: spamd: unauthorized connection from my.full.local.addr [my.local.ip] at port 54006 at /usr/sbin/spamd line 1271.

I needed to explicitly allow my local IP using -A. So, I need to start up spamd from the command line on my remote server with spamd -D -i my.remote.ip -p 783 -A my.local.ip.

Running my example now shows a warn: spamd: bad protocol: header error: (EOF during headers) error, because of how I'm opening the socket in my simple example. If I use the GitHub repo I linked, it now returns correctly.

Luke Shaheen
  • 4,262
  • 12
  • 52
  • 82