1

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

X-MSYS-API: {
  "campaign_id": "my_campaign",
  "metadata" : {
    "has_pets": true,
    "pet_name": "Spot"
  },
  "cc": [
    { "email": "cc_recip_1@gmail.com", "name": "CC 1" },
    { "email": "cc_recip_2@gmail.com", "name": "CC 2" }
  ],
  "bcc": [
    { "email": "bcc_recip_1@gmail.com", "name": "BCC 1" }
    { "email": "bcc_recip_2@gmail.com", "name": "BCC 2" }
  ],
  "archive": [
    { "email": "archive_recip_1@gmail.com", "name": "Archive 1" }
    { "email": "archive_recip_2@gmail.com", "name": "Archive 2" }
  ],
  "tags": [
    "cat",
    "dog"
  ],
  "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?

2

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

$body = "Some content";
$mail = JFactory::getMailer();
$mail->addRecipient("recipient@example.com");
$mail->setBody($body);
$mail->setSender(array("sender@example.com", "John Doe"));
$mail->setSubject("My Subject");
$data = array(
"options" => array("transactional" => "true")
);
$options = json_encode( $data );
$mail->AddCustomHeader("X-MSYS-API", $options);
$mail->Send(); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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