This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Add attachment to auto responder email *VERSION 3*


  1. steve
    Member

    This is just a quick hardcoded way to add an attachment to an auto response email after someone fills out your form.

    File location: /includes/helper-functions.php
    Line #748

    Change this:

    $s_message = Swift_Message::newInstance()
    			->setCharset('utf-8')
    			->setMaxLineLength(1000)
    			->setSubject($subject)
    			->setFrom(array($from_email => $from_name))
    			->setSender($from_email)
    			->setReturnPath($from_email)
    			->setTo($email_address)
    			->setBody($email_content, $email_content_type);

    To this:

    $s_message = Swift_Message::newInstance()
    			->setCharset('utf-8')
    			->setMaxLineLength(1000)
    			->setSubject($subject)
    			->setFrom(array($from_email => $from_name))
    			->setSender($from_email)
    			->setReturnPath($from_email)
    			->setTo($email_address)
    			->setBody($email_content, $email_content_type)
                            ->attach(Swift_Attachment::fromPath('http://www.domainname.com/filename.ext'));

    That will attach the file to the auto responder email. I just used an absolute url to the file, in my case I wanted to attach a vCard (.vcf) to the auto responder email.

    Hope this helps someone.

    Posted 11 years ago #
  2. yuniar

    Thank you for sharing this, Steve!


    MachForm Founder

    Posted 11 years ago #
  3. gbuecker
    Member

    What about the code that follows your addition?

    //attach files, if any
    if(!empty($files_to_attach)){
    foreach ($files_to_attach as $file_data){
    $s_message->attach(Swift_Attachment::fromPath($file_data['filename_path'])->setFilename($file_data['filename_value']));
    }
    }
    Is this a holder from a previous version or a possible future addition?

    Thanks,
    Glen

    Posted 11 years ago #
  4. yuniar

    Glen -- that one is the code to send the uploaded files as attachment. This one already part of the core MachForm.

    The one posted by steve above is the code to attach any file (located anywhere on your server) to the autoresponder email.


    MachForm Founder

    Posted 11 years ago #
  5. stephenheath
    Member

    I would like to add an attachment to the outoresponder email, but just on one form - I assume the code above would include the attachment for all forms?

    Posted 10 years ago #
  6. yuniar

    Yes, the above code would add it to all of your forms. To apply the code to certain form, you'll need to enclose the code with "IF" statement block.


    MachForm Founder

    Posted 10 years ago #
  7. stephenheath
    Member

    Possible feature for a future release?

    Posted 10 years ago #
  8. AguilaFan
    Member

    Being able to add an attachment WITHIN the form itself might be another way to go. Could use the IF function and/or just add a field that defines location of form to include it in email.
    Better yet, let them download it with by clicking a link in the email confirmation.
    Just add a clickable hyperlink in email.

    For now, I just redirect them to a page on website with forms so they download them.

    Person filling form would opt /select 1-2-3 different forms to be included in auto response.

    Have talent agency.
    Once they fill out section with needed items, and if they can work in a movie, then the get:
    1- Details for wardrobe
    2- map to Base Camp
    3- Agency notes on what to do/not do.

    Posted 10 years ago #
  9. HoughtonCR
    Member

    I agree that function would be excellent to be able to provide. This is for two scenarios:

    1) We get a great many requests for brochure request forms for websites. The web browser fills in a brochure request, it is stored in the database and we would love to be able to send a file(s) with the auto confirmation email.

    2) Whenever you sell something it is a good idea to send the terms and conditions of sale. Again from this form the ability to add a T's&C's file to the email would be excellent.

    Please please please?

    Posted 9 years ago #
  10. businessschool
    Member

    I am after the same functionality, that is a form that is a request for a file of some type e.g. information pack, the notification email sent to the poster has the file attached.

    As a simple and functional work around I embedded a link to the file/s requested in the body of the notification email (it accepts HTML). There is an added upside to this method, if you update the info pack/file/files (T & C's), replace the existing files keeping the same name, any contact that has the original email with the link will ALWAYS get the most up to date version of the file

    Hope that helps

    Posted 8 years ago #

RSS feed for this topic

Reply