Support » Plugins and Hacks » [Resolved] [Plugin: Contact Form 7] Attachment Issue

[Resolved] [Plugin: Contact Form 7] Attachment Issue

  • I ran into an issue with attaching files to an email through a contact form. I’m using the form for a lengthy financing application, so it’s pretty complex.

    I can confirm I can send email with the correct attachment with the following method:

    $header = "Content-type:text/plain; charset=iso-8859-1\r\n";
    $testmail = wp_mail("myemail@myemail.com", "test", "testing this email thing", $header, array($_SERVER['DOCUMENT_ROOT']."/wp-content/themes/thematic/coffee.zip"));

    I was going through the CF7 code and found where I thought the issue might be: classes.php does this:

    if ( $this->uploaded_files ) {
      $for_this_mail = array();
      foreach ( $this->uploaded_files as $name => $path ) {
        if ( false === strpos( $mail_template['attachments'], "[${name}]" ) )
        $for_this_mail[] = $path;
      return @wp_mail( $recipient, $subject, $body, $headers, $for_this_mail );

    The email would come in with just the name in the body of the email, which in the shortcode replacement part of CF7 makes sense.

    I believe this is an issue with the path being added since I can replace $for_this_mail with array($_SERVER[‘DOCUMENT_ROOT’].”/wp-content/themes/thematic/coffee.zip”) and it works fine.



Viewing 7 replies - 1 through 7 (of 7 total)
  • I did some more investigating and got it to work!

    comment out the following lines in classes.php:

    if ( false === strpos( $mail_template['attachments'], "[${name}]" ) )

    I believe this was checking to make sure the attachments matched up with the uploaded files, but it just plain doesn’t work.

    Mike, thank you. I was having this problem, and this solved it! 🙂

    Glad I could help.

    Thanks Mike. That solved it. If someone has found a problem to the endless ajax loader please post. It now sends the message+attachment, but doesn’t give the success msg.

    Thanks Mike – I’ve also had this problem and this solution worked.
    It’s nearly a year since you posted this – it would be great if the code could be fixed as I only downloaded the plugin today. I will direct the plugin author to this post.

    I can second this problem. This should be fixed ASAP.

    @gaybo did you notify the author?

    The author doesn’t offer an email address at his website. However, these forum postings are reproduced on his own website – so, if he reads them, hopefully he’ll find the time to act.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] [Plugin: Contact Form 7] Attachment Issue’ is closed to new replies.