I'm using an e-mail provider (sparkpost) for sending mail from my Joomla! website. Some mails are marketing e-mails others are transactional e-mails.

The default e-mail setting in sparkpost is 'marketing'. There is an option to overrule this: add a SMTP header to the e-mail which states the e-mail is transactional.

I'm sending mail with the JMail class. I'd like to add this extra sparkpost header named X-MSYS-API to e-mails, which can contain params as JSON data.

The option to add to the header is option.transactional:false

  "campaign_id": "my_campaign",
  "metadata" : {
    "has_pets": true,
    "pet_name": "Spot"
  "cc": [
    { "email": "[email protected]", "name": "CC 1" },
    { "email": "[email protected]", "name": "CC 2" }
  "bcc": [
    { "email": "[email protected]", "name": "BCC 1" }
    { "email": "[email protected]", "name": "BCC 2" }
  "archive": [
    { "email": "[email protected]", "name": "Archive 1" }
    { "email": "[email protected]", "name": "Archive 2" }
  "tags": [
  "options" : {
    "open_tracking": false,
    "click_tracking": false,
    "transactional": false,
    "sandbox": false,
    "skip_suppression": false,
    "ip_pool": "sp_shared",
    "inline_css": false

Does JMail support adding a SMTP header?

1 Answer 1


Ah, I've found it: AddCustomHeader(). Output looks OK like this:

$body = "Some content";
$mail = JFactory::getMailer();
$mail->addRecipient("[email protected]");
$mail->setSender(array("[email protected]", "John Doe"));
$mail->setSubject("My Subject");
$data = array(
"options" => array("transactional" => "true")
$options = json_encode( $data );
$mail->AddCustomHeader("X-MSYS-API", $options);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.