Description
Use this feature to dispatch a newsletter. Compared to Newsletter-Dispatch (II) you have to provide the recipients when using this feature. The result will be an object containing the ID of the newly created newsletter. This enables you to retrieve statistics for this newsletter using the features Newsletter-Statistics and Backclick-Statistics.
Available starting from Backclick-Version: 5.7.5
In order to create/dispatch a newsletter you have to provide the following information:
- Newsletter recipients as an array containing the following information
- Subscribers E-Mail address
- Mailing lists the subscriber is supposed to subscribe to
- Mandator ID
- Double-Opt-In template ID for subscribing to new mailing lists (default: âdoubleOptInTemplateIdâ => 0 (no template)); optional
- Profile-Change template ID for modifying subscriber data sets (default: âchangeProfileTemplateIdâ => 0 (no template)); optional
- Subscriber data
- Name of the field (mandatory field when providing subscriber data)
- Value of the field (mandatory field when providing subscriber data)
- Substitution for the variable $$SPECIAL-REPLACEMENT-TEXT$$ (default: âadhockInformationâ => ââ) optional
- Subject of the newsletter
- Content of the newsletter, you can either provide the content directly or use the ID of an existing newsletter template
- HTML or textual content of the newsletter
- Alternative text of the newsletter (when using HTML content)
- Newsletter template ID
- Mandator ID
- Time to dispatch the newsletter
- Senders name displayed (default: âsenderNameâ => ââ) optional
- Senders E-Mail address (default: âsenderEmailâ => ââ) optional
- API-Key (optional authentication, if not provided the IP address will be used for authentication)
The status of your request will be displayed as a result. It includes information about success or failure. If the request was successful, the response includes the ID of the newly created newsletter as well.
The following error messages can occur in a faulty request:
- No templateId AND no newsletterContent given!
- No subject given.
- Validation error => The request does not meet the requirements. Details can be found in the error message.
- Invalid domain of sender address (âexample.comâ). If you want to send email from this domain, please contact your admin. => The sender domain given cannot be used with this mandator.
- Invalid templateId! => The template ID given does not exist.
Example
$client = new SoapClient($wsdlUrl);
$sendNewsletterRequest = new StdClass();
$sendNewsletterRequest->mandatorId = 0;
$sendNewsletterRequest->newsletterContent = utf8_encode("<html><body>HTML-Inhalt des Newsletters</body></html>");
$sendNewsletterRequest->alternativeContent = utf8_encode("Text-Inhalt des Newsletters");
$sendNewsletterRequest->subject = utf8_encode("Betreff des Newsletters");
$sendNewsletterRequest->senderName = "Absendername";
$sendNewsletterRequest->senderEmail = "[email protected]";
$sendNewsletterRequest->subscribers = array();
date_default_timezone_set('Europe/Berlin');
$sendNewsletterRequest->sendTime = time();
$subscriber = new StdClass();
$subscriber->mandatorId = 0;
$subscriber->subscriberEmail = "[email protected]";
$subscriber->newsletterListIds = array(1);
$subscriber->subscriberFields = array();
$subscriberField = new StdClass();
$subscriberField->fieldName = utf8_encode ("VORNAME");
$subscriberField->fieldValue = utf8_encode ("Vorname");
array_push($subscriber->subscriberFields, $subscriberField);
$subscriberField = new StdClass();
$subscriberField->fieldName = utf8_encode ("NACHNAME");
$subscriberField->fieldValue = utf8_encode ("User");
array_push($subscriber->subscriberFields, $subscriberField);
array_push($sendNewsletterRequest->subscribers, $subscriber);
try {
$result = $client->sendNewsletter($sendNewsletterRequest);
var_dump($result);
} catch (Exception $e) {
echo "\n" . $e->getMessage() . "\n";
if (is_array($e->detail->ValidationError)) {
foreach ($e->detail->ValidationError as $ve) {
echo $ve . "\n";
}
} else {
echo $e->detail->ValidationError . "\n";
}
}
object(stdClass)#6 (2) {
["success"]=>
bool(true)
["newsletterId"]=>
int(10254)
}
Source code
In order to test a working example you can download the source code.
Example for dispatching a newsletter
Â