Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have installed the Contact Form 7 plugin on my WP 3.2.1 instance.

I have setup a contact form for users to request evaluations.

This is all working fine, but I was hoping that when they submitted a request, I could ping them an email with an attached product brochure.

I have it currently setup like this:

enter image description here

I have tried using [file-691] where 691 is the id of the uploaded media in the media gallery.

Both do not seem to work.
What is the correct way to achieve this?

share|improve this question

closed as off-topic by Rarst Jul 24 at 16:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

6 Answers 6

As far as I know, the feature you are trying to use is not meant to be used this way. It is in fact meant to give the submitter the option to upload a file that is send with his mail message.

I don't think such a feature is available for contact form 7

share|improve this answer

CF7 won't work that way. What you're trying to do needs to be set up at the server or email client level, not at the application level in WP.

Set up an email auto-responder on your email server or in your email client.

share|improve this answer

Sorry for my bad english and my even more worse PHP skills.

You can use email-before-download but... didn't got it working like i wanted. I tried a little bit of code and i think this is working. not the finest way, but you can use the link to the file within the attachment field in the admin-gui. Just enter there something like "wp-content/uploads/2013/05/File.pdf" (without the quotes) instead of "[file-1234]" and put the following code into your functions.php

function mycustom_cf_before_action(&$wpcf7_data) {
    global $mailcounter;
    $mailcounter = 0;
    if ((!empty($wpcf7_data->mail['attachments'])) and (!(0 === strpos($wpcf7_data->mail['attachments'], '['))) ) {
        global $cmail1;
        $cmail1 = '';
        $cmail1 = $wpcf7_data->mail['attachments'];
    }
    if ((!empty($wpcf7_data->mail_2['attachments'])) and (!(0 === strpos($wpcf7_data->mail_2['attachments'], '['))) ) {
        global $cmail2;
        $cmail2 = '';
        $cmail2 = $wpcf7_data->mail_2['attachments'];
    }
}
add_action('wpcf7_before_send_mail', 'mycustom_cf_before_action',1);

function mycustom_wpcf7_mail_components($components){
    global $cmail1;
    global $cmail2;
    global $mailcounter;

    if (($mailcounter == 0) and (!empty($cmail1)) and (empty($components['attachments']))) {
          $components['attachments'][] = $cmail1;
    }
    if (($mailcounter == 1) and (!empty($cmail2)) and (empty($components['attachments']))) {
          $components['attachments'][] = $cmail2;
    }
    $mailcounter = $mailcounter + 1;
    return $components;
}

add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );

The first function checks if there are "static" attachments. so anything that doesn't start with [ or is empty

The second function is adding the static attachment when sending. Tried to use the "uploaded_files" but then the attachments are deleted. Since the Components part is the same for mail1 and mail2 you have to count somehow. Thats the reason for $mailcounter. $cmail1 and $cmail2 is to get the links to the attachments into the components-part. CF7 doesn't care anymore about the original contact form data at this point. so this was the only solution I saw at this point.

share|improve this answer

Try email-before-download used with download monitor plugin. These integrate with CF7 beautifully and all you need to do is select ATTACHMENT to be sent as an email instead of an inline download link. Works beautifully.

share|improve this answer
    
Try reformatting your answer with more specifics. –  Brian Fegter Sep 29 '12 at 5:19
    
@aly22, could you point me to the right source "email-before-download" –  alex Feb 17 '13 at 19:34

I believe this is the plugin referred to: https://wordpress.org/plugins/email-before-download/

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.