The Inx_Api_Mailing_MailingManager manages all mailings.
The Inx_Api_Mailing_MailingManager manages all mailings. The MailingManager can be used to perform the following tasks:
There are several ways to retrieve mailings. The simplest way is to call selectAll() which will retrieve all mailings. To retrieve a single mailing, use the get($iMailingId) method. To retrieve all mailings of a specific list use one of the select(...) methods. Using this type of method gives you the ability to define search filters, like the mailing state. It is also possible to order the result.
The following snippet shows how to retrieve all mailings of a specific list, which are either in the
$oMailingManager = $oSession->getMailingManager(); $oBOResultSet = $oMailingManager->select($oListContext, Inx_Api_Mailing_Mailing::STATE_DRAFT | Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE); for( $i = 0; $i < $oBOResultSet->size(); $i++ ) { $oMailing = $oBOResultSet->get($i); echo $oMailing->getName()."<br>"; } $oBOResultSet->close();To retrieve all mailings of a specific list, disregarding their state, use the state filter STATE_FILTER_ALL. This filter produces the same result as a bitwise combination of all mailing states.
If needed, it is possible to create much more complex select statements than the one above. This can be accomplished using filter expressions. The following snippet extends the previous select statement with a filter that restricts the result to mailings which were modified during the last hour. The result is also ordered by the mailing name:
$oMailingManager = $oSession->getMailingManager(); $filterDate = date("d.m.Y H:i:s", strtotime("-1 hour")); $filter = "Attribute(".Inx_Api_Mailing_Mailing::ATTRIBUTE_MODIFICATION_DATETIME.") > #".$filterDate."#"; $oBOResultSet = $oMailingManager->select($oListContext, Inx_Api_Mailing_Mailing::STATE_DRAFT | Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE, $filter, Inx_Api_Mailing_Mailing::ATTRIBUTE_NAME, Inx_Api_Order::ASC); for($i = 0; $i < $oBOResultSet->size(); $i++) { $oMailing = $oBOResultSet->get($i); echo $oMailing->getName()."<br>"; } $oBOResultSet->close();
<strong>Mailing creation and editing</strong>
The following snippet shows how to create a mailing:
$oMailingManager = $oSession->getMailingManager(); $oMailing = $oMailingManager->createMailing($oListContext); $oMailing->updateSubject("Monthly Newsletter"); $oMailing->commitUpdate();
<strong>Note:</strong> For existing mailings, always call lock() before updating it, and unlock() after committing changes!
The following snippet shows how to edit an existing mailing:
$oMailingManager = $oSession->getMailingManager(); $oMailing = $oMailingManager->get($iMailingId); try { $oMailing->lock(); $oMailing->updateSubject("New Subject"); $oMailing->commitUpdate(); $oMailing->unlock(); } catch(Inx_Api_LockException $x) { //somone else has locked this mailing }
It is not necessary to repeatedly create almost identical mailings. This can be accomplished a lot easier using the clone() method.
The following snippet shows how to clone a mailing and put the clone in the specified list:
$oMailingManager = $oSession->getMailingManager(); $oMailingManager->cloneMailing($iMailingId, $oListContext);
<strong>Preview generation</strong>
To create a preview of a mailing, an Inx_Api_Mail_MailingRenderer is needed. A renderer can be obtained using the createRenderer() method.
The following snippet shows how to create a
$oMailingManager = $oSession->getMailingManager(); $oMailingRenderer = $oMailingManager->createRenderer(); $oMailingRenderer->parse($iMailingId, Inx_Api_Mail_MailingRenderer::BUILD_MODE_PREVIEW); $oMailContent = $oMailingRenderer->build($iRecipientId); echo $oMailContent->getPlainText()."<br>";
For more information on mailings, see the Inx_Api_Mailing_Mailing documentation.
Note: To use mailings, the following api user right is required: Inx_Api_UserRights::MAILING_FEATURE_USE
Located in /Api/Mailing/MailingManager.php (line 137)
Inx_Api_BOManager | --Inx_Api_Mailing_MailingManager
Copies a
Copies a
Creates a new mailing in the specified list.
Creates a new mailing in the specified list.
Creates the new Inx_Api_Mail_MailingRenderer to rendering a Inx_Api_Mailing_Mailing.
Creates the new Inx_Api_Mail_MailingRenderer to rendering a Inx_Api_Mailing_Mailing.
Creates the new
to rendering aCreates the new
to rendering aSelects mailings in specified order, filtered by the supplied condition. The Inx_Api_BOResultSet contains a set of Inx_Api_Mailing_Mailing objects.
Selects mailings in specified order, filtered by the supplied condition.
The Inx_Api_BOResultSet contains a set of Inx_Api_Mailing_Mailing objects.
The stateFilter must be either a single value like:
$filterDate = date("d.m.Y H:i:s");The orderAttribute is the id of the order attribute. Allowed values for attribute ids are:
Inherited From Inx_Api_BOManager
Inx_Api_BOManager::get()
Inx_Api_BOManager::remove()
Inx_Api_BOManager::selectAll()
State filter constants to returning all mailings.
State filter constants to returning all mailings. It's the same like:
$iStateFilter = Inx_Api_Mailing_Mailing::STATE_DRAFT | Inx_Api_Mailing_Mailing::STATE_TO_BE_APPROVE | Inx_Api_Mailing_Mailing::STATE_APPROVED | Inx_Api_Mailing_Mailing::STATE_SCHEDULED | Inx_Api_Mailing_Mailing::STATE_SENDING| Inx_Api_Mailing_Mailing::STATE_INTERRUPTED | Inx_Api_Mailing_Mailing::STATE_SENT | Inx_Api_Mailing_Mailing::STATE_SENDING_FAILED;
Documentation generated on Thu, 17 Sep 2015 14:27:27 +0200 by phpDocumentor 1.3.2