Attaching a file to the autoreply email

This documentation page is for Quform version 1 and may not be applicable for Quform 2 click here to visit the documentation for Quform 2.

This guide will show you how to attach a static file to the autoreply email.

Step 1

You’ll need to set up the form to send an autoreply email first, by going to Form Builder → Settings → Email → Autoreply email settings, tick Send autoreply email and configure the settings.

Step 2

Add the following code to the wp-content/themes/YOUR_THEME/functions.php file (or create a plugin for it).

1
2
34
5
6
7
function my_attach_autoreply_file(PHPMailer $mailer, $form, $attachments)
{
    $mailer->AddAttachment(ABSPATH . '/Document.pdf', 'Document.pdf', 'base64', 'application/pdf'); 
    return $mailer;
}
add_filter('iphorm_pre_send_autoreply_email_1', 'my_attach_autoreply_file', 10, 3);
function my_attach_autoreply_file(PHPMailer $mailer, $form, $attachments)
{
    $mailer->AddAttachment(ABSPATH . '/Document.pdf', 'Document.pdf', 'base64', 'application/pdf');

    return $mailer;
}
add_filter('iphorm_pre_send_autoreply_email_1', 'my_attach_autoreply_file', 10, 3);

Modify the code as follows:

  • On line 3, change ABSPATH . '/Document.pdf' to the absolute path of the file you want to attach, the current code will attach the file Document.pdf inside the WordPress root directory.
  • On line 3, change Document.pdf to the desired name of the file that will be shown to the user as the attachment filename
  • On line 3, change application/pdf to the MIME type of the file, you can find the MIME type on this page
  • On line 7, change the number 1 to the form ID
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy