Bitspan Knowledge Base Article - 100005

How to automate Bitspan Spamity™ Agent from Linux

 

 

SUMMARY

This article provides an overview of programming Bitspan Spamityä Agent using Automation from another program.

MORE INFORMATION

Bitspan provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures.

 

For more information about the support options that are available and about how to contact Bitspan, visit the following Bitspan Web site:

http://www.bitspan.com/

 

Linux (CPP)

To use Bitspan’s Spamity™ Agent, download the latest Spamity Package for Linux from Bitspan. To do this, follow these steps:



Spamity.h file

 //-----------------------------------------------------------------------------
//Exported functions
//-----------------------------------------------------------------------------
void  GetLastErrorDescription(char* pErr);
void  ClearLastErrorDescription ();
int   GetVersionMajor ();
int   GetVersionMinor ();
long  SetWebProxy(char* proxy_address, int proxy_port);
void  SetKey(char *key);

long  UpdateDefinitions(int nThreadMode);
long  Terminate();

long  IsSpam(char* body, char* sTo, char* sCC, char* sFrom, char* sReplyTo, char* sIP, int& nDefNum); 
long  IsSpamByIP (const char* sIP);
long  IsSpamByMime (char * mime_body, int & nDefNum);
long  IsSpamByMimeIP (char * mime_body);

int  GetDefinitionCount();
int  GetIPCount();


main.ccp

 //Sample code for calling IsSpam function
#include 
#include 
#include "Spamity.h"
using namespace std;

int main(int argc, char* argv[])    
{
	int DefNum = 0; 
	//  
	// Set the license key 
	// 
	//   IMPORTANT NOTE:
	//   YOU NEED A LICENSE KEY FROM BITSPAN TO GET THE LATEST DEFINITIONS
	//   YOU CAN GET A TRIAL KEY BY VISITING http://www.bitspan.com/spamity			 

	SetKey("LICENCE KEY GOES HERE");
	
	//The first time UpdateDefinitions function is called, it may take a few 
	//minutes to return. It should take shorter time once the definitions are 
	//automatically cached and stored on the hard drive. 
	//After that you can call IsSpam function against your emails.
	//Updates will be downloaded automatically and will not affect 
	//the IsSpam processing time.
	
	UpdateDefinitions(1);

	//To do: Replace "Email body" with the body of your email.
	//       Change "to", "cc", "from", "replyto" parameters with 
	//       the corresponding values from your email. The latest  
	//       parameters are optional, but you can get a more accurate 
	//       result by using them.
	
	//Check whether an email is spam or not
	
	long result = IsSpam("Email body","to","cc","from","replyto",NULL,DefNum);

	//Check results of IsSpam function call
	
	if(result != 0)	printf("\nThe email was spam\n");
	else printf("\nThe email may be legitimate\n");

	//For having a graceful termination/clean up,it is better to call Terminate().
	
	Terminate();

	return 1;
}

 

REFERENCES

For more information about creating solutions with Bitspan Spamityä, please see the following articles in the Bitspan Knowledge Base:

100002 How to Automated Bitspan Spamity™ from Visual C++
100003 How to Automated Bitspan Spamity™ from SOAP/HTTP

The information in this article applies to:

Last Reviewed:

14/05/2005 (1.0)

Keywords:

kbdtacode kbhowto kbProgramming kbusage KB100005