« Back to Documentation Overview

campaignSendTest – v1.1

 campaignSendTest(string apikey, string cid, array test_emails, string send_type)

Send a test of this campaign to the provided email address

Section
Campaign Related
Parameters
apikey a valid API Key for your user account. Get by calling Get by visiting your API dashboard
cid the id of the campaign to test
test_emails an array of email address to receive the test message
send_type optional - by default (null) both formats are sent - "html" or "text" send just that format
Returns
boolean true on success

Examples (2)

download example code

[1] mcapi_campaignSendTest.php

  1. <?php
  2. /**
  3. This Example shows how to send Campaign Tests via the MCAPI class.
  4.  
  5. Note that a max of 25 of these may be sent
  6. **/
  7. require_once 'inc/MCAPI.class.php';
  8. require_once 'inc/config.inc.php'; //contains apikey
  9.  
  10. $api = new MCAPI($apikey);
  11.  
  12. $emails = array($my_email, $boss_man_email);
  13. $retval = $api->campaignSendTest($campaignId, $emails);
  14.  
  15. if ($api->errorCode){
  16. echo "Unable to Send Test Campaign!";
  17. echo "\n\tCode=".$api->errorCode;
  18. echo "\n\tMsg=".$api->errorMessage."\n";
  19. } else {
  20. echo "Campaign Tests Sent!\n";
  21. }
  22.  

[2] xml-rpc_campaignSendTest.php

  1. <?php
  2. /**
  3. This Example shows how to immediately Send a Test message for a prepared Campaign
  4. using XML-RPC.
  5. Note that a max of 25 of these may be sent
  6. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  7. **/
  8. require_once 'XML/RPC2/Client.php';
  9. require_once 'inc/config.inc.php';
  10. try {
  11. $client = XML_RPC2_Client::create($apiUrl);
  12.  
  13. $emails = array($my_email, $boss_man_email);
  14. $result = $client->campaignSendTest($apikey, $campaignId, $emails);
  15. echo "SUCCESS! \n";
  16. echo "Returned: ".$result."\n";
  17.  
  18. } catch (XML_RPC2_FaultException $e){
  19. echo "ERROR!!!!\n";
  20. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  21. }
  22. ?>
  23.  
  24.