Description
Use this feature to create and dispatch a newsletter. Compared to Newsletter-Dispatch (I) you do not have to provide the recipients every time using this feature. You can send newsletters to existing mailing lists or profile filters instead. 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.8.0
In order to create/dispatch a newsletter you have to provide the following information:
- Subject of the newsletter
- API-Key (optional authentication, if not provided the IP address will be used for authentication)
- Mandator ID
- Newsletter recipients (you have to provide at least one of the following, providing both fields is possible as well. When only providing the profile filter the target group newsletter will be used)
- Mailing list ID
- List of profile filter IDs
- 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
- Substitution for the variable $$SPECIAL-REPLACEMENT-TEXT$$ (default: “adhockInformation” => “”) optional
- Time to dispatch the newsletter (default: “sendTime” => 0) optional
- Senders name displayed (default: “senderName” => “”) optional
- Senders E-Mail address (default: “senderEmail” => “”) optional
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:
- 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.
- Validation error => The request does not meet the requirements. Details can be found in the error message.
- No templateId AND no newsletterContent given!
- No subject given.
- Invalid templateId! => The template ID given does not exist.
- Autoimport is running. Please try again later. => An automatic import that would affect the newsletter is currently running.
- Filter with ID #id is non existent.
- No Recipients are given! => You neither provided a newsletter-list-ID nor a profile filter. There are no recipients available this way.
Example
$client = new SoapClient($wsdlUrl);
$createMailingRequest = new StdClass();
$createMailingRequest->mandatorId = 0;
$createMailingRequest->newsletterContent = utf8_encode("<html><body>HTML-Inhalt des Newsletters</body></html>");
$createMailingRequest->alternativeContent = utf8_encode("Text-Inhalt des Newsletters");
$createMailingRequest->subject = utf8_encode("Betreff des Newsletters");
$createMailingRequest->senderName = "Absendername";
$createMailingRequest->senderEmail = "[email protected]";
$createMailingRequest->recipients = new StdClass();
$createMailingRequest->recipients->newsletterListId = 1;
date_default_timezone_set('Europe/Berlin');
$createMailingRequest->sendTime = time();
try {
$result = $client->createMailing($createMailingRequest);
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)#4 (2) {
["success"]=>
bool(true)
["newsletterId"]=>
int(10153)
}Source code
In order to test a working example you can download the source code.
Example for dispatching a newsletter