Search code examples
phpmailersparkpost

SparkPost sending with PHPmailer - how do I disable open and click tracking?


I know that sending emails with SparkPost via the API, I can disable open and click tracking with:

options.open_tracking set to false
options.click_tracking set to false

However, I'm sending with PHPmailer. I can't have my email links be converted to gibberish. I need the actual links, not the SparkPost converted links. From what I understand, this will be achieved by not tracking opens and clicks with SparkPost email.

Thanks in advance


Solution

  • You need to use X-MSYS-API custom header.

    $x_msys_api = array(
      'options' => array (
        'open_tracking' => false,
        'click_tracking' => false
      )
    );
    
    $phpmailer->addCustomHeader('X-MSYS-API', json_encode($x_msys_api));
    

    I assumed you've $phpmailer object (instance of PHPMailer class), replace it accordingly.

    Here is official documentation. Here is an example use.