21493 Posts in 5784 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1828 Views |
-
Attachment on email generated from a form

5 September 2009 at 11:28am
Hi
I have a form which generates a response email to the submitter but I want this to include an attachment but I am not sure how to do this. I have included into the code file for the form but the email arrives without an attachment:$From = $data['Email'];
$To = $data['Email'];
$Subject = "blah balh" ;
$Attachment = "assets/Uploads/blahblah.pdf";
$email = new Email($From, $To, $Subject,'',$Attachment);Does anyone know? Is there any documentation that might help me?
Thakns
MM
-
Re: Attachment on email generated from a form

5 September 2009 at 11:44am
Apparently it should be an array of filenames
i.e. $Attachment = array("blahblah.pdf");
but then where do I put the blahblah.pdf file so that it knows where to get it from?
Thanks
MM
-
Re: Attachment on email generated from a form

5 September 2009 at 5:16pm
Ok, so I was heading off down the wrong track. I think I am on the right on now but still no cigar.
There is a method in the email class, attachFile but I can't get it to work. I call it
$To = $data['Email'];
$Subject = "blahblah" ;
$email = new Email($From, $To, $Subject);
//set template
$email->setTemplate('MFEmail');
//populate template
$email->populateTemplate($data);
//attach file
$email->attachFile("blahblah.pdf");
//send mail
$email->send();but still no attachment on the email. Whats missing/wrong? I can't find any documentation on this either. Am happy to work it out for myself if I just knew where to look
Thanks
MM
-
Re: Attachment on email generated from a form

5 September 2009 at 6:56pm
attachFile() is correct. This takes the filename from the base url so if your pdf is in your assets folder you would need to do
$email->attachFile('assets/file.pdf');
-
Re: Attachment on email generated from a form

6 September 2009 at 6:28pm
Thanks, I thought I had already tried this but no. It works a treat.
MM
| 1828 Views | ||
|
Page:
1
|
Go to Top |

