Advertisement

03.06.2008 at 02:38PM PST, ID: 23221385
[x]
Attachment Details

Trouble using spamd in Ubuntu under VMWare

Asked by JTennessen in Spam Assassin, Ubuntu

Tags: , ,

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
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
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";
            }
        }
    }
}
[+][-]03.07.2008 at 12:50AM PST, ID: 21068339

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Spam Assassin, Ubuntu
Tags: SpamAssassin, C#, No connection could be made because the target machine actively refused it
Sign Up Now!
Solution Provided By: grblades
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628