I want to create a custom Email that includes an attachment that the user has uploaded, as well as a link to the attachment. Is there a way to do that?

1. In your form's properties, make sure that the "Mail Notification" checkbox is UNCHECKED.


2. Copy the code below.

$this->execPieceByName('ff_InitLib');
$from = ff_getSubmit('email');
$fromname = ff_getSubmit('Name');
$subject = 'Your Email Subject'; // Change to your preferred Email subject
$recipient = 'your@email.com'; // Change to your admin Email address
$body = '';
       
      if (count($this->maildata)){
          foreach ($this->maildata as $data){

                $testEx = explode("\n", trim($data[_FF_DATA_VALUE]));
                $cntTestEx = count($testEx);
                if($cntTestEx > 1){
                      for($ex = 0; $ex < $cntTestEx; $ex++){
                            if(!is_array($attachment) && $attachment != ''){
                                    $attachment = array_merge(array(trim($testEx[$ex])), array($attachment));
                            }                            
                            else if(is_array($attachment)){
                                    $attachment = array_merge(array(trim($testEx[$ex])), $attachment);
                            }                            
                            else{
                                    $attachment = trim($testEx[$ex]);
                            }
                      }
                }                
                else{
                      if(!is_array($attachment) && $attachment != ''){
                             $attachment = array_merge(array(trim($data[_FF_DATA_VALUE])), array($attachment));
                      }                      
                      else if(is_array($attachment)){
                             $attachment = array_merge(array(trim($data[_FF_DATA_VALUE])), $attachment);
                      }
                      else {
                             $attachment = trim($data[_FF_DATA_VALUE]);
                      }
                }

           }
     } 


foreach ($this->maildata as $data) {

  if( $data[_FF_DATA_NAME] == 'upload' )
{
   $body .= $data[_FF_DATA_TITLE].': http://www.yourdomain.com/path/to/uploads/' . basename($data[_FF_DATA_VALUE]);
} else {
   $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";

  }
}

$this->sendMail($from, $fromname, $recipient, $subject, $body, $attachment);  // This line actually emails the form.

 



3. Make Changes to the Code as Needed - IMPORTANT!

You will need to replace the text below (within the single quotation marks) with your own Email Subject and admin Email address, respectively.

$subject = 'Your Email Subject'; // Change to your preferred Email subject
$recipient = 'your@email.com'; // Change to your admin Email address

 

And change the path to your uploads folder in:

 

$body .= $data[_FF_DATA_TITLE].': http://www.yourdomain.com/path/to/uploads/' . basename($data[_FF_DATA_VALUE]);

 

4. Once you have edited and copied the code, go to Form Properties > Advanced Tab, and click on the "More Options" link.

5. Go to the SUBMIT PIECES tab, to the END SUBMIT section, and click on the CUSTOM radio button. That will open a text area into which you should paste the code that you just edited and copied.

6. Click on the SAVE icon at the bottom of that screen to save the code you just added.

7. Once back at the base page of your form, click on the SAVE icon in the upper right-hand corner of the screen to save the form itself.

8. Test your form to see if it works.

 

I like this, but I want to send my form to multiple Admin emails. Can I do that?

 

Yes, you can. Delete this line in the code above:

$recipient = 'your@email.com'; // Change to your admin Email address

 

And then replace the last line of code:

 

$this->sendMail($from, $fromname, $recipient, $subject, $body, $attachment);  // This line actually emails the form.

with:

$this->sendMail($from, $fromname, "yourAdmin1@email.com", $subject, $body, $attachment);  // This line actually emails the form.
$this->sendMail($from, $fromname, "yourAdmin2@email.com", $subject, $body, $attachment);  // This line actually emails the form.
$this->sendMail($from, $fromname, "yourAdmin3@email.com", $subject, $body);  // This line would send an Email but would NOT include the attachment, if you need that option.

 

This code can be added as many times as needed -- one for each Email address you need to send out.

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!