If you are maintaining mailing lists on Sailthru for mass mail campaigns, you will want your code to make API calls to Sailthru to keep those lists current whenever users sign up and/or change their mail preferences.
To subscribe an email address to a mailing list, use the setEmail() method in the client. setEmail() takes an email address, replacement vars, and lists.
Replacement vars should be in key/value format, where the key is the var name and the value is the var value.
Lists should be in key/value format, where the key is the list name and the value is either 1 (for "subscribe") or 0 for ("unsubscribe"). If the list does not exist, it will be created automatically.
A user with the email address joe@example.com has signed up, and we want to put him in the everybody and schmoefamily lists, and set a couple of replacement variables so we can include his name when we mail him.
$client = new Sailthru_Client(); $client->setEmail('joe@example.com', array('name' => 'Joe Schmoe'), array('everybody' => 1, 'schmoefamily' => 1));
We want to unsubscribe Joe from the everybody list but simultaneously sign him up for the foobar list.
$client = new Sailthru_Client(); $client->setEmail('joe@example.com', array(), array('everybody' => 0, 'foobar' => 1));
Here's the equivalent of Example #1 as an API call, if you're not using the client or you're using the Test API functionality:
email=joe@example.com vars[name]=Joe Schmoe lists[everybody]=1 lists[schmoefamily]=1
See also: email API call.