• Hi,
    i’m trying to automatically add attachment with this code:

    add_action(‘wpcf7_before_send_mail’, ‘send_pdf’);
    function send_pdf() {
    $submission = WPCF7_Submission::get_instance();
    $submission->add_uploaded_file(‘pdf_file’, get_template_directory().’/test.pdf’);
    }

    I added in file attachments field this: [pdf_file] and also i added this in form: [file pdf_file filetypes:pdf limit:2mb] – this code is probably unnecessary.

    And no attachment is sent. What i’m missing ?

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tomot

    (@tomot)

    It is working. I just realized that, after code is executed pdf file is deleted from server. And pdf apparently was deleted even when in code was error and later when code was good, there was no file on server to send.

    CF7 deletes all uploaded files for security reasons.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamically send pdf attached to mail’ is closed to new replies.