Hello,
To send attachments depending on the checkboxes or send multiple-emails will requre a custom solution since there isn't an option to simply set this.
Here is how to achieve what you want.
You have to go to
Advanced options of your form
> More options > Submit pieces and in the
End Submit section, select
Type Custom and there you have to create an email. Here is an example of the code that will do what you want:
$this->execPieceByName('ff_InitLib');
$from = 'your@email.com'; //change to wanted email
$fromname = 'yourname'; //change to wanted from name
$subject = 'Your Email Subject'; // Change to your preferred Email subject
$attachment = [];
//$ischeck[]= ff_getSubmit('check');
$body = '';
$rec = ['0','0','0'];
foreach ($this->maildata as $data) {
if( $data[_FF_DATA_NAME] == 'checkboxgroupname'){
$ischeck = $data[_FF_DATA_VALUE];
if (strpos($ischeck, 'checkboxvalue1') !== false) {
array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/attachemnt1.pdf'); }
if (strpos($ischeck, 'checkboxvalue2') !== false) {
array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/attachment2.pdf'); }
if (strpos($ischeck, 'checkboxvalue3') !== false) {
array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/attachment3.pdf'); }
}
if( $data[_FF_DATA_NAME] == 'selectlistname'){
$isselect = $data[_FF_DATA_VALUE];
if (strpos($isselect, 'selectvalue1') !== false) {
$rec[0]= '1'; }
if (strpos($isselect, 'selectvalue2') !== false) {
$rec[1]= '1'; }
if (strpos($isselect, 'selectvalue3') !== false) {
$rec[2]= '1'; }
}
$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
}
if( $rec[0]=='1') {$this->sendMail($from, $fromname, 'mustermann@muster1.de', $subject, $body, $attachment); }
if( $rec[1]=='1') {$this->sendMail($from, $fromname, 'mustermann@muster2.de', $subject, $body, $attachment); }
if( $rec[2]=='1') {$this->sendMail($from, $fromname, 'mustermann@muster3.de', $subject, $body, $attachment); }
Here is what changes you need to make to the code other then the ones noted in the code:
1) Replace checkboxgroupname with the Name of the checkbox group where attachments are selected.
2) Replace checkboxvalue1, checkboxvalue2 and checkboxvalue3 with values of checkboxgroup options.
3) This is a code for attachments placed in They both are located in /media/breezingforms/pdftpl folder. Replace /media/breezingforms/pdftpl/attachemntnr.pdf with the correct path to the attachments, and adjust attachments names.
4) Replace selectlistname with the Name of the select list where emails are selected.
5) Replace selectvalue1, selectvalue2 and selectvalue3 with the values of that select list options.
6) In sendmail functions adjust the emails to the wanted ones if necessary.
The content of the emails you define in the $body.
I hope that this will help you. Let me know if you have managed to set this for your form.
If you have more questions, feel free to ask.
Regards,
Mihaela