CF8 send email with multiple dynamic attachments

How to send multiple dynamic attachments in ChronoForms 8.

Overview

The issue occurs because the standard email action cannot process an array of file paths stored in a single variable.
Apply a core code change to the email action's output file to allow the {var:attachments} variable to accept and merge an array of file paths.

Answered
ChronoForms v8
pi pimh 19 Oct, 2025

Hi Max, 

I need to send multiple attachments from files dynamically created in a loop. The number of iterations in the loop determine the number of attachments. The loop depends on the results of a query, so unknown at forehand.My questions is how to fill a {var:attachments} with multiple paths to attachments? I tried using /r/n as linebreaks between paths, without success. Also other methods to insert linebreaks I tried, without luck. Is there another solution? 

Many thanks, Pim

Max_admin Max_admin 20 Oct, 2025
Answer

Hi Pim

You will need a core code change for this, open this file:

/joomla/administrator/components/com_chronoforms8/pages/chronoforms/actions/email/output.php

Around line 23 you will find this code block:

if(!empty($action['attachments'])){
	$lines = CF8::multiline($action['attachments']);
	foreach($lines as $line){
		$attachments[] = CF8::parse($line->name);
	}
}

Change it to:

if(!empty($action['attachments'])){
	$lines = CF8::multiline($action['attachments']);
	foreach($lines as $line){
		$atts = CF8::parse($line->name);
		if(is_array($atts)){
			$attachments = array_merge($attachments, $atts);
		}else{
			$attachments[] = $atts;
		}
	}
}

Then use {var:attachments} in the attachments box, just a single line with no spaces or anything in order for this to work

The new code will be available in the next update

Let me know how it works

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Post a Reply