WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Attachment Issue (8 posts)

  1. MikeNGarrett
    Member
    Posted 3 years ago #

    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}]" ) )
          continue;
        $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.

    Thoughts?

    http://wordpress.org/extend/plugins/contact-form-7/

  2. MikeNGarrett
    Member
    Posted 3 years ago #

    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}]" ) )
    continue;

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

  3. Enis
    Member
    Posted 3 years ago #

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

  4. MikeNGarrett
    Member
    Posted 3 years ago #

    Glad I could help.

  5. inetwerx
    Member
    Posted 2 years ago #

    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.

  6. graybo
    Member
    Posted 2 years ago #

    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.

  7. JohnnyPea
    Member
    Posted 2 years ago #

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

    @gaybo did you notify the author?

  8. graybo
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic