Adding attachments to an non-default email template

4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 11, 2023   (RSS)

By JeffC - October 7, 2023

I would like to be able to add attachments to one of my email templates.

I've found these instructions in /lib/mail_functions.php. But this file only contains the code for the default email templates. I would like to add attachments to a template that I have added. Where can I find these?

Thanks

  // Full Featured Example:

  $errors = sendMessage(array(
    'from'    => "from@example.com",
    'to'      => "to@example.com",
    'subject' => "Enter subject here, supports utf-8 content",
    'text'    => "Text message content",
    'html'    => "<b>HTML</b> message content",

   'headers' => array(
      "CC"              => "cc@example.com",
      "BCC"             => "bcc@example.com",
      "Reply-To"        => "rt@example.com",
      "Return-Path"     => "rp@example.com",
      "x-custom-header" => "12345",
    ),

    'attachments' => array(
      'simple.txt'  => 'A simple text file',
      'dynamic.csv' => $csvData,
      'archive.zip' => $binaryData,
      'image.jpg'   => file_get_contents($imagePath),
    ),
Jeff

By Dave - October 7, 2023

Hi Jeff, 

What code is sending the message?  Is it custom or Newsletter Builder or something else?  

What we'd need to do is all the attachment options to the sending code.

Let me know some details and we'll see what's possible.

Dave Edis - Senior Developer
interactivetools.com

By JeffC - October 8, 2023

Thanks Dave

It's a email set up in the Email Templates section editor (https://domain.co.uk/cmsb/admin.php?menu=_email_templates)

The site uses the Membership Plugin to send an email to a new user when signing up. The template ID is the default one (USER-SIGNUP) that the plugin creates.

We'd like to add a 'Welcome Pack' as an email attachment (which consists of 2 Word .docs.

Thanks

Jeff