You are here

function MCAPI::listSubscribe in Mailchimp 5

Same name and namespace in other branches
  1. 5.2 MCAPI.class.php \MCAPI::listSubscribe()
  2. 6.2 MCAPI.class.php \MCAPI::listSubscribe()
  3. 6 MCAPI.class.php \MCAPI::listSubscribe()
  4. 7 MCAPI.class.php \MCAPI::listSubscribe()

Subscribe the provided email to a list

Related

@example mcapi_listSubscribe.php @example xml-rpc_listSubscribe.php

Parameters

string $id the list id to connect to:

string $email_address the email address to subscribe:

array $merge_vars array of merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays). Note that a merge field can only hold up to 255 characters. Also, there are 2 "special" keys:: string INTERESTS Set Interest Groups by passing a field named "INTERESTS" that contains a comma delimited list of Interest Groups to add. string OPTINIP Set the Opt-in IP fields. <i>Abusing this may cause your account to be suspended.</i>

string $email_type optional - email type preference for the email (html or text, defaults to html):

boolean $double_optin optional - flag to control whether a double opt-in confirmation message is sent, defaults to true. <i>Abusing this may cause your account to be suspended.</i>:

Return value

boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)

File

./MCAPI.class.php, line 733

Class

MCAPI

Code

function listSubscribe($id, $email_address, $merge_vars, $email_type = 'html', $double_optin = true) {
  $params = array();
  $params["id"] = $id;
  $params["email_address"] = $email_address;
  $params["merge_vars"] = $merge_vars;
  $params["email_type"] = $email_type;
  $params["double_optin"] = $double_optin;
  return $this
    ->callServer("listSubscribe", $params);
}