Forums

Adding file in reply email

blaauw 14 Mar, 2012
Goodafternoon,

Im am trying to build a fairly simple registration form. The problem i am having is that i want to send a email with a .pdf file as attachment as a reply after the registration.

So someone fills out the form , presses on the submit button and will receive a conformation email with a .pdf file as attachement.

Can anybody help me with this problem ( especially with the .pdf file as attachment)

thanks

steve
BernieG 14 Mar, 2012
Once you have setup the email, edit your form (NOT with the wizard), go to "Form Code" tab, select "on Submit code-before sending email" and enter there something like this:
<?php
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments = array('fullpathtomyfile.pdf');
?>
blaauw 14 Mar, 2012
BernieG

I am sorry but i lost you when you talked about :
edit your form (NOT with the wizard), go to "Form Code" tab, select "on Submit code-before sending email" and enter there something like this:

I use the version 4 and i am not sure where to put the code.

see images : http://test.edi-t.nl/index.php/chronoforms

any suggenstions ?
BernieG 14 Mar, 2012
Sorry, I am on version 3. The url you gave is for a Joomla site which is not online, it require to login.
blaauw 14 Mar, 2012
BernieG ,

i will set it online for 15 minutes

let me know

--- online now --
BernieG 14 Mar, 2012
I have been loking, but I am sorry, it's too different and I can't help you.
blaauw 14 Mar, 2012
BernieG

it looks like you are getting the uploaded file to send.

what i want to do is to attach a file which is stored under /images/ to the reply email.

i get an error with the following line : <?php
$MyUploads =& CFUploads::getInstance($form_id);

CFUploads is not recognized
GreyHead 15 Mar, 2012
Hi blauuw,

If you are using CFv4 then the CFv3 code won't work. The easiest answer is to use my Email [GH] action which has an option to attach a static file (i.e. one that is already saved rather than a new upload).

Bob
blaauw 15 Mar, 2012
Greyhead,

thanks for your reply. I turns out i need in the v3 version so i am back where i started.
Just installed the v3 version and applied the tip from BernieG but that didn't work ?

"Once you have setup the email, edit your form (NOT with the wizard), go to "Form Code" tab, select "on Submit code-before sending email" and enter there something like this:
<?php
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments = array('/images/test.pdf');
?>


Could you tell me if this script correct and is i use the right code within the array with the pdf file

steve
GreyHead 17 Mar, 2012
Hi Steve,

Here's the extract from Chapter 2 of The ChronoForms Book that talks about this

1. ChronoForms doesn't have a box that you can fill in to do this so we need to add some code to the OnSubmit Before box in the Form Editor.

If you already have code in the box – we added some in a previous recipe – that's fine. This code block can go before (or after) that one in the box. ChronoForms adds the form attachments to a $attachments array and we are going to add an extra entry to that. The code is short, once you know what it is:

<?php
$form_id = $MyForm->formrow->id;
$MyUploads =& CFUploads::getInstance($form_id);
$MyUploads->attachments[] = 'images/newsletter.pdf';
?>

Taking this line by line:
$form_id = $MyForm->formrow->id;

This gets the form ID, the entry you see in the first column of the Forms Manager. This is the internal identifier for the form and must be unique.
$MyUploads =& CFUploads::getInstance($form_id);

This gets a copy of a ChronoForms object that holds the uploads information for this form. In this case it's empty but if there had been files uploaded for the form, the information about them would be temporarily stored here.
$MyUploads->attachments[] = 'images'.DS.'newsletter.pdf';

This adds a new "upload" entry to the ChronoForms Uploads Object, though in this case it's not an upload but our static file. ChronoForms isn't fussy and will quite happily accept this.

Note that the path uses .DS. instead of / or \, because the Default Separator (DS) can vary depending on the server Joomla! adopts this more flexible version. We've used the partial path here 'images'.DS.'newsletter.pdf', to be a bit more thorough we could have added the fuller JPATH_ROOT.DS.'images'.DS.'newsletter.pdf'

With those three lines in place ChronoForms will attach the sample newsletter file to each e-mail that it sends out.

Note that if you have more than one e-mail setup then the file will be attached to both of them unless you disable attachments on one or the other. At the moment, there is no way of having two Email Setups with different file attachments (though it could be achieved by hand coding an e-mail setup).


Bob
bruceluis 28 Mar, 2013
Hi,
I might be doing something wrong but when I complete and submit my form I don't get the email with the attachment.
I installed your action and under "File Attachments" I put the full path: "http://mysite.com/images/stories/test.pdf"
What am I doing wrong?
BernieG 28 Mar, 2013
I believe this: http://mysite.com/images/stories/test.pdf is wrong.
If you don't put a relative path, like /Images/Stories/etc, you need to put the PHYSICAL path to the file, something like D:/path-to-my-site/images/stories/etc....
GreyHead 28 Mar, 2013
Hi bruceluis,

BernieG is correct.

This is a URL
http://mysite.com/images/stories/test.pdf
and this is a folder path
D:/path-to-my-site/images/stories/etc....

Bob
bruceluis 28 Mar, 2013
Excellent! thank you for your replies.
I changed the path to "images/stories/test.pdf"
but, I'm not receiving the email when I do a test.
What am I missing here?
Thanks in advance!
GreyHead 28 Mar, 2013
Hi bruceluis,

Maybe you need a / in the front? What do you see when you add a debugger action?

Bob
bruceluis 28 Mar, 2013
Data Array:

Array
(
    [option] => com_chronoforms
    [chronoform] => ebook
    [event] => submit
    [Itemid] => 
    [name] => test
    [email] => test@test.com
    [username] => test
    [password] => test
    [password_confirm] => test
    [input_submit_5] => Submit
    [9f4d8b20ba4e908a4e9b0e05e63b455f] => 1
    [IPADDRESS] => 108.220.254.146
    [password2] => test
    [_PLUGINS_] => Array
        (
            [joomla_registration] => Array
                (
                    [id] => 70
                    [name] => test
                    [username] => test
                    [email] => test@test.com
                    [password] => bc7beb05a287d40f276168818cbe9023:VbzePq8GEavm2jJbu2Q3R0boWMWyPFpJ
                    [password_clear] => test
                    [usertype] => Registered
                    [block] => 
                    [sendEmail] => 0
                    [gid] => 18
                    [registerDate] => 2013-03-28 20:52:02
                    [lastvisitDate] => 
                    [activation] => 
                    [aid] => 0
                    [option] => com_chronoforms
                    [chronoform] => ebook
                    [event] => submit
                    [Itemid] => 
                    [password_confirm] => test
                    [input_submit_5] => Submit
                    [9f4d8b20ba4e908a4e9b0e05e63b455f] => 1
                    [IPADDRESS] => 108.220.254.146
                    [password2] => test
                )

        )

)

Validation Errors:

Array
(
)

 

 

test, thank you for requesting the eBook, your information has been successfully received.

You will be receiving an email with the eBook as an attachment.

Please add our email address (info@miamifastseo.com) to your email's account's safe list to prevent our messages to be forwarded to the junk folder.

 

 
Debug Data

    Email info
        Email sent successfully
        From: (Admin) info@miamifastseo.com
        Reply to: (Admin) info@miamifastseo.com
        To: info@miamifastseo.com
        Subject: SEO eBook
    Email body
        6 Ways to get on top results! - eBook request form

        In order to receive our eBook registration is required.
        Full Name 	test
        Email address 	test@test.com
        Create a Username 	test
        Create a Password 	test
        Confirm Password 	test
        By clicking the "Submit" button you agree to share your information with Miami Fast SEO.
        You can review our Privacy Policy here.

        Submitted by 108.220.254.146
bruceluis 28 Mar, 2013
I just copied everything the debugger showed me.
GreyHead 29 Mar, 2013
Hi bruceluis,

The thread that you have linked to is about ChronoForms v3 but I think that you are using ChronoForms v4.

Please see this FAQ

Bob
bruceluis 03 Apr, 2013
After following the steps in the FAQ is giving me this error and I'm not getting the email with the attachment:
Parse error: syntax error, unexpected '.', expecting ')' in /home/content/25/4900925/html/sites/miamifastseo/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(18) : eval()'d code on line 8
GreyHead 03 Apr, 2013
Hi bruceluis,

What is on line 8 of your Custom Code?

Bob
bruceluis 04 Apr, 2013
this is everything on that code:
<?php
if ( !isset($form->data['checkboxes']) || count($form->data['checkboxes']) == 0 ) {
  return;
}
$files_array = array (
  1 => JPATH_SITE.'/images/stories/test.pdf',
  
  . . .
);
$attach_files = array();
foreach ( $files_array as $k => $v ) {
  if ( in_array($k, $form->data['checkboxes']) ) {
    $attach_files[] = $v;
  }
}
$form->data['file_array'] = $attach_files;
?>
bruceluis 04 Apr, 2013
Also, the form is not sending the email at all to the user.
GreyHead 04 Apr, 2013
Hi bruceluis,

Where it says . . . you need to complete the array.

Bob
bruceluis 04 Apr, 2013
OK, but I have no idea how to complete it. Is that the reason why users are not getting the email?
bruceluis 05 Apr, 2013
Can I just remove the dots?
GreyHead 05 Apr, 2013
Hi bruceluis,

If you only have one file to attach that should work OK. Please try it to see.

Bob
bruceluis 05 Apr, 2013
Yes, I have only one file. So, if I remove the dots it should work right?
bruceluis 05 Apr, 2013
Is not giving me the error now, but, I'm no getting the email😟
Should I post here the code maybe?
GreyHead 05 Apr, 2013
Hi Bruceluis,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

Note: if you are using the Easy Wizard you can turn on Debug on the Others tab.

Bob
bruceluis 05 Apr, 2013
Here it is Bob, I really appreciate your help
Data Array:

Array
(
    [option] => com_chronoforms
    [chronoform] => ebook
    [event] => submit
    [Itemid] => 
    [name] => Pedro Gonzalez
    [email] => bruceluisito@hotmail.com
    [username] => test
    [password] => test
    [password_confirm] => test
    [input_submit_5] => Submit
    [ba658933c8fa5adf1b1b47dbd1aefff3] => 1
    [IPADDRESS] => 108.220.254.146
    [password2] => test
    [_PLUGINS_] => Array
        (
            [joomla_registration] => Array
                (
                    [id] => 84
                    [name] => Pedro Gonzalez
                    [username] => test
                    [email] => bruceluisito@hotmail.com
                    [password] => c3478729463bd11334a058f0258031f2:MYnwC28rbIqn3X3oxht14hG2t1v4d8Y5
                    [password_clear] => test
                    [usertype] => Registered
                    [block] => 
                    [sendEmail] => 0
                    [gid] => 18
                    [registerDate] => 2013-04-05 21:35:23
                    [lastvisitDate] => 
                    [activation] => 
                    [aid] => 0
                    [option] => com_chronoforms
                    [chronoform] => ebook
                    [event] => submit
                    [Itemid] => 
                    [password_confirm] => test
                    [input_submit_5] => Submit
                    [ba658933c8fa5adf1b1b47dbd1aefff3] => 1
                    [IPADDRESS] => 108.220.254.146
                    [password2] => test
                )

        )

)

Validation Errors:

Array
(
)

 

 

Pedro Gonzalez, thank you for requesting the eBook, your information has been successfully received.

You will be receiving an email with the eBook as an attachment.

Please add our email address (info@miamifastseo.com) to your email's account's safe list to prevent our messages to be forwarded to the junk folder.

 

 
Debug Data

    Email info
        Email sent successfully
        From: (Admin) info@miamifastseo.com
        Reply to: (Admin) info@miamifastseo.com
        To: info@miamifastseo.com
        Subject: SEO eBook
    Email body
        6 Ways to get on top results! - eBook request form

        In order to receive our eBook registration is required.
        Full Name 	Pedro Gonzalez
        Email address 	bruceluisito@hotmail.com
        Create a Username 	test
        Create a Password 	test
        Confirm Password 	test
        By clicking the "Submit" button you agree to share your information with Miami Fast SEO.
        You can review our Privacy Policy here.

        Submitted by 108.220.254.146

GreyHead 06 Apr, 2013
Hi bruceluis,

Have you added the attachment to the Email action? It's not showing in the Debug info.

There is no value for file_array in the debug either so I suspect that isn't working. There may be a typo or error in the PHP.

Bob
bruceluis 11 Apr, 2013
Bob, this is what I got (see attachment)
GreyHead 11 Apr, 2013
hi bruceluis,

I think I see the problem. The code you are using is based on selecting files from checkboxes in the form but you don't have a checkbox so nothing is selected. If you don't want to use checkboxes then you can remove that part of the code.

Bob
bruceluis 11 Apr, 2013
I'm lost here. My main problem is that I don't receive emails after people fill out the form. If possible, can you help me out fixing that problem? and then it could be easier to fix the attachment problem.
Thanks a lot!
GreyHead 12 Apr, 2013
Hi Bruceluis,

I'm sorry, you posted in a thread about "Adding file in reply email" so that's what gets my attention.

Please see this FAQ

From your debug code it looks as though the From and To addresses are the same; this can result in emails being dropped.
From: (Admin) info@miamifastseo.com
Reply to: (Admin) info@miamifastseo.com
To: info@miamifastseo.com


Bob
This topic is locked and no more replies can be posted.