|
|
Documentation Wiki > Developer Documentation > Web Service Guide > Technical Articles > SpamAssassin Integration
SpamAssassin IntegrationFrom $1Table of contents
(Click the banner to go to the related Docs.Code.ExactTarget.com page.) The integration with SpamAssassin allows you to subject your email to the SpamAssassin logic to see how it would score. A high score means that parts of the email are likely to be identified as spam by email servers and the email is more likely to be rejected. You must use the web service API to get an email's SpamAssassin score. You make an API call with the email to test and the system responds with a message that contains the following elements:
PrerequisitesYou must be an API customer of ExactTarget to utilize SpamAssassin, and you must use an existing email and subscriber list as part of the test. SpamAssassin Best PracticesExactTarget recommends that emails return a score of 3.0 or lower from a SpamAssassin check in order to get past the majority of SpamAssassin installations. The SpamAssassin rules listed below represent common errors that can be easily corrected, causing your SpamAssassin score to decrease. For best results, set up a test subscriber list you can use to evaluate the email without risk of a premature send to your existing subscribers. This API call will work with dynamic content, but it does not work with data extensions. Results will display based on the user interface your company has set up to receive information from the API call. You can set the spam threshold score to be more or less stringent that the SpamAssassin default, depending on your needs. The validation information will return up to 1 minute following the call's send. MIME_HTML_ONLYMail sent as HTML only can cause a 1.9 point increase to your email's SpamAssassin score. Make sure to send your emails with multi-part MIME enabled. Contact your ExactTarget representative for more information on the multi-part MIME feature. HTML_IMAGE_RATIOEmails containing a large number of images or a low ratio of text to images may incur a .2 to .9 point increase to the SpamAssassin score. To correct this issue, include more text in your emails or reduce the size and number of your images. HTML_TAG_BALANCE_BODYFailing to close the <body> tag in your HTML email earns your email a 1.1 increase on your SpamAssassin score. Be sure to close all tags in your email, including the <body> tag. DEAR_FRIENDAvoid using the phrase "dear friend" in your email, as it earns the email a 2.7 point increase. Spam messages commonly include this phrase. FROM_OFFERSAvoid including the word "offers" in your email address. This increase an email's SpamAssassin score by 2.7 points. Use a real, valid email address as part of your email send to avoid this problem. HTML_FONT_LOW_CONTRASTIf an email's font color is similar to the email's background color, the SpamAssassin score may increase by .7 points. Increase the contrast between font and background to avoid this problem. Sample CodeUse the sample code below to perform the activities specified in the heading: SOAP Envelope for Testing Messages<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>Perform</wsa:Action>
<wsa:MessageID>urn:uuid:73887d4b-9672-47a8-9536-1d8d230b6972</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>https://webservice.exacttarget.com/Service.asmx</wsa:To>
<wsse:Security soap:mustUnderstand="1">
<wsse:UsernameToken wsu:Id="SecurityToken-2b8e1caa-1c56-406e-a2a7-34eb2cfbf804">
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Options>
<RequestType>Asynchronous</RequestType>
</Options>
<Action>Validate</Action>
<Definitions>
<Definition xsi:type="ContentValidation">
<ValidationAction xsi:type="SpamAssassinValidation"/>
<Email>
<ID>6123476</ID>
<ObjectID xsi:nil="true"/>
</Email>
<Subscribers>
<Subscriber>
<ObjectID xsi:nil="true"/>
<EmailAddress>test@example.com</EmailAddress>
</Subscriber>
</Subscribers>
</Definition>
</Definitions>
</PerformRequestMsg>
</soap:Body>
</soap:Envelope>
Perform Call to Validate SpamAssassin Check///<summary>
/// Spam Assassign should always be performed using ASync call. If you are using Synchronous you will
/// experience timeouts.
///
/// Once you make API call, capture RequestId and then use that to Retrieve details of SPAM check uisng
/// ResultMessage. ResultMessage returns XML data in ResultDetailXML property. Clients have to process that XML string
/// and identify score inside it.
///</summary>
public void testCheckforSpam()
{
ContentValidation validation = new ContentValidation();
validation.ValidationAction = new SpamAssassinValidation();
;
Email email = new Email();
email.ID = 3756825;
email.IDSpecified = true;
validation.Email = email;
//Subscriber should exists in ALL subscribers, Otherwise system will not work.
//Spam Assassin will work only with List based subscribers. Not supported for DataExtension subscribers.
Subscriber subscriber = new Subscriber();
subscriber.EmailAddress = "test@example.com";
Subscriber[] subscribers = {subscriber};
validation.Subscribers = subscribers;
APIObject[] validationObjs = {validation};
PerformResult[] results = null;
String requestId = null;
String OverallStatus = null;
String OverallStatusMsg = null;
PerformOptions options = new PerformOptions();
options.RequestType = RequestType.Asynchronous;
options.RequestTypeSpecified = true;
results =
soapClient.Perform(options, "Validate", validationObjs, out OverallStatus, out OverallStatusMsg,
out requestId);
if (results != null)
{
Console.Write("Results :: " + results);
}
}
Check for SpamAssassin Score///<summary>
/// Retrieve ResultMessage Object.
///</summary>
public void testRetrieveResultMessage()
{
APIObject[] results;
RetrieveRequest rr = new RetrieveRequest();
rr.ObjectType = "ResultMessage";
rr.Properties = new string[] { "StatusMessage", "ErrorCode", "RequestType", "ResultDetailXML" };
SimpleFilterPart filter = new SimpleFilterPart();
filter.Property = "RequestID";
filter.SimpleOperator = SimpleOperators.equals;
filter.Value = new string[] { "f53b06d7-6186-4491-989c-bbf160616cd1" };
rr.Filter = filter;
// Execute RetrieveRequest
String status = soapClient.Retrieve(rr, out requestID, out results);
// Output the Values
Console.WriteLine(status);
Console.WriteLine(requestID);
Console.WriteLine(results.Length);
Console.WriteLine("_________Properties______________");
}
SOAP Response for ResultMessage<soap:Body>
<RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<OverallStatus>OK</OverallStatus>
<RequestID>b08956a2-9acc-44d9-8376-fec6f8aaa62e</RequestID>
<Results xsi:type="ResultMessage">
<CreatedDate>2009-07-29T21:00:27.453</CreatedDate>
<ObjectID xsi:nil="true"/>
<StatusMessage/>
<RequestType>Asynchronous</RequestType>
<ResultType>ContentValidationResult</ResultType>
<ResultDetailXML><![CDATA[<ContentValidationResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://exacttarget.com/wsdl/partnerAPI">
<StatusCode>OK</StatusCode>
<Object xsi:type="ContentValidation">
<ObjectID xsi:nil="true" />
<ValidationAction xsi:type="SpamAssassinValidation" />
<Email>
<ID>123</ID>
<ObjectID xsi:nil="true" />
</Email>
<Subscribers>
<Subscriber>
<ID>123</ID>
<ObjectID xsi:nil="true" />
<EmailAddress>test@example.com</EmailAddress>
<Lists>
<ID>881272</ID>
<ObjectID xsi:nil="true" />
</Lists>
</Subscriber>
</Subscribers>
</Object>
<Task xsi:type="ContentValidationTaskResult">
<StatusCode />
<StatusMessage />
<ID>e076ffda-575c-496b-a1d5-9f51629e4d35</ID>
<ValidationResults>
<ValidationResult>
<Subscriber>
<ID>378445620</ID>
<ObjectID xsi:nil="true" />
<EmailAddress>test@example.com</EmailAddress>
<Lists>
<ID>881272</ID>
<ObjectID xsi:nil="true" />
</Lists>
</Subscriber>
<IsResultValid>true</IsResultValid>
<IsSpam>false</IsSpam>
<Score>-1.4</Score>
<Threshold>5</Threshold><Message />
</ValidationResult>
</ValidationResults>
</Task>
</ContentValidationResult>]]>
</ResultDetailXML>
</Results>
</RetrieveResponseMsg>
</soap:Body>
PHP Perform SpamAssassin Call<?php
require('exacttarget_soap_client.php');
$wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';
try{
/* Create the Soap Client */
$client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
/* Set username and password here */
$client->username = 'XXX';
$client->password = 'XXX';
$po = new ExactTarget_Options();
$po->RequestType = ExactTarget_RequestType::Asynchronous;
$poe = new SoapVar($po, SOAP_ENC_OBJECT, 'PerformOptions', "http://exacttarget.com/wsdl/partnerAPI");
$pr = new ExactTarget_PerformRequestMsg();
$pr->Action = "Validate";
$pr->Definitions = array();
$def = new ExactTarget_ContentValidation(); $email = new ExactTarget_Email();
$email->ID = '3096380';
$sub = new ExactTarget_Subscriber();
$sub->EmailAddress = 'help@example.com';
$def->Email = $email;
$def->Subscribers = array($sub); $sa = new ExactTarget_SpamAssassinValidation();
$sae = new SoapVar($sa, SOAP_ENC_OBJECT, 'SpamAssassinValidation', "http://exacttarget.com/wsdl/partnerAPI");
$def->ValidationAction = $sae;
$pr->Definitions[] = new SoapVar($def, SOAP_ENC_OBJECT, 'ContentValidation', "http://exacttarget.com/wsdl/partnerAPI");
$pr->Options = $poe;
echo 'before call';
$results = $client->Perform($pr);
echo 'Status: '.$results->StatusMessage.'<br>';
echo 'OverallStatusMessage: '.$results->OverallStatusMessage.'<br>';
echo 'RequestID: '.$results->RequestID.'<br>';
} catch (SoapFault $e) {
var_dump($e);
} ?>
PHP Retrieve Results Call<?php
require('exacttarget_soap_client.php');
$wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';
try {
/* Create the Soap Client */
$client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
/* Set username and password here */
$client->username = 'XXX';
$client->password = 'XXX';
$sfp = new ExactTarget_SimpleFilterPart();
$sfp->Property = "RequestID";
$sfp->SimpleOperator = ExactTarget_SimpleOperators::equals;
$sfp->Value = array("411f970f-3a26-4011-ac05-17d43a2f0545");
$rr = new ExactTarget_RetrieveRequest();
$rr->ObjectType = "ResultMessage";
$rr->Properties = array( "RequestID","StatusCode", "StatusMessage", "ResultDetailXML");
$rr->Filter = new SoapVar($sfp, SOAP_ENC_OBJECT, 'SimpleFilterPart', "http://exacttarget.com/wsdl/partnerAPI");
$request = new ExactTarget_RetrieveRequestMsg();
$request->RetrieveRequest = $rr;
$results = $client->Retrieve($request);
echo '<br>';
echo 'StatusCode: '.$results->Results->StatusCode.'<br>';
echo 'StatusMessage: '.$results->Results->StatusMessage.'<br>';
echo 'ResultDetailXML: '.$results->Results->ResultDetailXML.'<br>';
} catch (SoapFault $e) {
var_dump($e);
} ?>
This page was last updated by Ryan Williams on Fri, 06 Jan 2012 21:24:39 GMT. If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:
Tags: (Edit tags)
|
Powered by MindTouch 2010 |