Service: CreateEmailAddress

The CreateEmailAddress service allows you to create a new email address within a Flexmail mailing list. The ID of the newly created email address will be returned to you.

Service Details

SOAP Action: CreateEmailAddress
SOAP Return Object: CreateEmailAddressResp

Input

The following table describes the parameters used for calling the CreateEmailAddress service.

Table: instance of CreateEmailAddressReq

Parameter Mandatory Type Description
header Y APIRequestHeader Header for authentication
mailingListId / Integer Id of the mailing list the in which the new email address will be made
emailAddressType Y EmailAddressType The email address to be added
optInType / OptInType An optional type to send an opt-in message after the email address is created
sources / Array of SourceType Array with sources objects

Output

The following table describes the parameters returned from the CreateEmailAddress service.

Table: instance of CreateEmailAddressResp

Parameter Mandatory Type Description
header / APIResponseHeader Header containing authentication information
errorCode / Integer Numerical value of the error
errorMessage / String Short literal description of the error
emailAddressId / Integer Id of the new email address

Table: response codes of CreateEmailAddressResp.

0 No error
220 Authentication error, see header object for detailed information
221 Mailing list id is mandatory
222 Mailing list id is invalid
223 Email address is mandatory
224 Email address is invalid
225 Email address already exists
226 Invalid opt-in message
227 Invalid opt-in reply email
228 Invalid opt-in sender email
229 Opt-in sender name is mandatory
230 Opt-in subject is mandatory
231 Email address is blacklisted
232 Subscription plan limit reached
233 emailAddressType's language is invalid

Example

This example shows you the creation of a new email address, john.doe@flexmail.eu, in a mailing list.

<?php
$header->userId = USER_ID;
$header->userToken = USER_TOKEN;

$createEmailAddressReq->header = $header;
$createEmailAddressReq->mailingListId = 4563;
$createEmailAddressReq->emailAddressType = new stdClass();
$createEmailAddressReq->emailAddressType->emailAddress = "john.doe@flexmail.eu";
$createEmailAddressReq->emailAddressType->name = "John";
$createEmailAddressReq->emailAddressType->surname = "Doe";

// if custom fields / database manager fields are applicable
$customFields = array();
$field = new stdClass;
$field->variableName = "my_var_name";
$field->value = "field value";

array_push($customFields, $field);
$createEmailAddressReq->emailAddressType->custom = $customFields;

// if an opt-in is required
$optIn = new stdClass();
$optIn->messageId = 1234;
$optIn->subject = "Please confirm you mailinglist registration";
$optIn->senderName = "My Company";
$optIn->senderEmail = "info@example.com";
$optIn->replyEmail = "no-reply@example.com";
$optIn->formId = 1234; // optional, the ID of your optIn form. Eg. you can assign different optIn forms depending on contact language
$createEmailAddressReq->optInType = $optIn;
$createEmailAddressResp = $SoapClient->__soapCall("CreateEmailAddress", array($createEmailAddressReq));

if ($createEmailAddressResp->errorCode == 0) {
	echo "Email address created, mailing list id:" . $createEmailAddressResp->emailAddressId;
} else {
	echo Email address creation failed: " . $createEmailAddressResp->errorMessage;
}
?>