Link to home
Start Free TrialLog in
Avatar of Jeff Tennessen
Jeff TennessenFlag for United States of America

asked on

Trouble using spamd in Ubuntu under VMWare

Hey folks,

I'm brand new to SpamAssassin and Linux. I am trying to set up a proof-of-concept project whereby a C# application connects to a spamd server, passes it the text of an RFC2822 message, and receives the details about whether the message is spam.

I have set up Ubuntu 7.10 in VMWare Server 1.0.4 build-56528. The host OS is Windows Server 2003, SP1. I installed SpamAssassin, and spamd appears to be running, according to the System Monitor. I started it with the following command:

# sudo spamd -d -c -m 5 -A 192.168.0.196 --helper-home-dir --pidfile=/var/run/spamd.pid

192.168.0.196 is the IP address of the host machine. #ps waux | grep spam returns the following:

root      7261  0.0  5.6  32480 29040 ?        Ss   15:04   0:02 /usr/sbin/spamd -d -c -m 5 -A 192.168.0.196 --helper-home-dir --pidfile=/var/run/spamdd.pid
root      7262  0.0  5.2  32480 27240 ?        S    15:04   0:00 spamd child
root      7263  0.0  5.2  32480 27152 ?        S    15:04   0:00 spamd child
1000      8814  0.0  0.1   2972   752 pts/0    R+   16:05   0:00 grep spam

# netstat -luntp | grep 783 returns:

tcp        0     0 127.0.0.1:783           0.0.0.0:*              LISTEN      -

However, when I try to connect from my C# app, I get the following error:

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

I've attached the code from my test app (adapted from VB.NET code found here: http://www.codeproject.com/KB/IP/spamc.aspx). When I run the application on the host server, this is what ends up in the TextBox:

Preparing data...
Sending data...

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at SATest.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\jtennessen\My Documents\Visual Studio 2005\Projects\SATest\SATest\Form1.cs:line 62

Because of my inexperience with SpamAssassin and Linux, I am unsure what to do to troubleshoot this. If anyone can point me in the right direction, I would be most grateful!

TIA,

Jeff

using System;
using System.Net;
using System.Text;
using System.Windows.Forms;
 
namespace SATest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                textBox1.Text += "Preparing data...\r\n";
 
                StringBuilder SB = new StringBuilder();
 
                SB.Append("PROCESS SPAMC/1.0");
                SB.Append("\r\nSubject: Test spam mail (GTUBE)");
                SB.Append("\r\nMessage-ID: <gtube1.1010101@example.net>");
                SB.Append("\r\nDate: Wed, 23 Jul 2003 23:30:00 +0200");
                SB.Append("\r\nFrom: Sender <sender@example.net>");
                SB.Append("\r\nTo: Recipient <recipient@example.net>");
                SB.Append("\r\nPrecedence: junk");
                SB.Append("\r\nMIME-Version: 1.0");
                SB.Append("\r\nContent-Type: text/plain; charset=us-ascii");
                SB.Append("\r\nContent-Transfer-Encoding: 7bit");
                SB.Append("\r\n");
                SB.Append("\r\nIf your spam filter supports it, the GTUBE " + 
                          "provides a test by which you");
                SB.Append("\r\ncan verify that the filter is installed " + 
                          "correctly and is detecting incoming");
                SB.Append("\r\nspam. You can send yourself a test mail " + 
                          "containing the following string of");
                SB.Append("\r\ncharacters (in upper case and with no white " +
                          "spaces and line breaks):");
                SB.Append("\r\n");
                SB.Append("\r\nXJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-" + 
                          "ANTI-UBE-TEST-EMAIL*C.34X");
                SB.Append("\r\n");
                SB.Append("\r\nYou should send this test mail from an " + 
                          "account outside of your network.");
                SB.Append("\r\n");
 
                Byte[] buffer = Encoding.ASCII.GetBytes(SB.ToString());
 
                textBox1.Text += "Sending data...\r\n";
 
                System.Net.Sockets.Socket socket = 
                    new System.Net.Sockets.Socket(
                        System.Net.Sockets.AddressFamily.InterNetwork,
                        System.Net.Sockets.SocketType.Stream,
                        System.Net.Sockets.ProtocolType.Tcp);
                IPEndPoint ipe = 
                    new IPEndPoint(IPAddress.Parse("192.168.31.128"), 783);
 
                //This is the line on which the error occurs:
                socket.Connect(ipe);
                socket.Send(buffer);
                socket.Shutdown(System.Net.Sockets.SocketShutdown.Send);
 
                textBox1.Text += "Receiving data\r\n";
 
                Int32 r;
 
                do
                {
                    Byte[] recbuf = new Byte[1024];
                    r = socket.Receive(recbuf);
                    textBox1.Text += Encoding.ASCII.GetString(recbuf, 0, r);
                }
                while (r != 0);
 
                textBox1.Text += "OK\r\n";
            }
            catch (Exception ex)
            {
                textBox1.Text += "\r\n" + ex.ToString() + "\r\n";
            }
        }
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of grblades
grblades
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeff Tennessen

ASKER

Yep, that does it! It leads to a new problem, but I'll start another Q for that. Thanks!

Jeff
Never mind, I figured out the other problem. Thanks again, grblades!

Jeff