UDT, attach formbuilder file upload to email

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
KayakMan
Forum Members
Forum Members
Posts: 19
Joined: Thu Mar 12, 2015 1:49 pm

UDT, attach formbuilder file upload to email

Post by KayakMan »

Hey,

I have another thread that this option can solve.... if I can attach a file uploaded through Formbuilder with a UDT and send it via CMSMailer. Note, files are being uploaded.

Note: 'Deny file to be attached with emails', is unticked.

Can anyone see a problem in my UDT with the file upload/attachment:

$actparams = $smarty->get_template_vars('actionparams');
$form_id = $actparams['form_id'];

if($form_id == 5) {
$mail = cms_utils::get_module('CMSMailer');

{* -- my file upload is {$attachcv} / {$fld_53} -- *}

if(!empty($params['fld_53'])) {
$fileupload = $params['fld_53'];
} else {
$fileupload = '';
}


$subject = " here ";
$body = " body of email ";
$mail->AddAddress( $destination );
$mail->IsHTML( true );
$mail->SetBody( $body );
$mail->SetSubject( $subject );
$mail->AddAttachment('$fileupload', 'PDF file', 'base64', 'application/pdf');
$mail->Send();
$mail->reset();
}

Also see http://forum.cmsmadesimple.org/viewtopi ... =8&t=67308
KayakMan
Forum Members
Forum Members
Posts: 19
Joined: Thu Mar 12, 2015 1:49 pm

Re: UDT, attach formbuilder file upload to email

Post by KayakMan »

Also a file is attached to emails when using a non UDT submission e.g.
'Email Results to set Address(es)'.
KayakMan
Forum Members
Forum Members
Posts: 19
Joined: Thu Mar 12, 2015 1:49 pm

Re: UDT, attach formbuilder file upload to email

Post by KayakMan »

I've tried the following:

//Attach an image file
//$mail->AddAttachment($file);
//$mail->AddAttachment($_fileupload['file']['tmp_name'], $_fileupload['file']['name']);

//$mail->AddAttachment("/uploads/cvs/$fileupload");

$mail->AddAttachment($path/$fileupload, 'PDF file', 'base64', 'application/pdf' );
KayakMan
Forum Members
Forum Members
Posts: 19
Joined: Thu Mar 12, 2015 1:49 pm

Re: UDT, attach formbuilder file upload to email

Post by KayakMan »

Okay, getting there :-)

This works. But my emailed PDFs are corruptly encoded.. they won't load ???.


$remote_path = 'http://www.domain.com/$fileupload';

$mail->AddStringAttachment($remote_path, $fileupload, $encoding = 'base64', $type = 'application/octet-stream');
User avatar
PinkElephant
Forum Members
Forum Members
Posts: 173
Joined: Fri Feb 06, 2009 2:08 pm

Re: UDT, attach formbuilder file upload to email

Post by PinkElephant »

KayakMan wrote: $mail->AddAttachment('$fileupload', 'PDF file', 'base64', 'application/pdf');
Looks like quoting the $fileupload variable passes '$fileupload' rather than the intended value.

(The docs suggest the AddAttachment method returns a boolean for success/failure so an if() might help deal with a bad path, etc).
Post Reply

Return to “Modules/Add-Ons”