Attach pdf to custom email

[ad_1]

Hello , i have this function who resent the woocommerce invoice to another email.

it work normally but without the attachement , i want to include the pdf attachement to it how i do it , i searched a lot but no hope

 <?php if (isset($_POST['submit'])) {
                function emailhtml( $order, $heading = false, $mailer ) {

                  $template = 'emails/invoice.php';

                return wc_get_template_html( $template, array(
               'order'         => $order,
              'email_heading' => $heading,
            'sent_to_admin' => false,
            'plain_text'    => false,
              'email'         => $mailer
             ) );
            
            }

          // load the mailer class
             $mailer = WC()->mailer();

            //format the email
            $recipient = $_POST['email'];
          $subject = __("Votre facture de chez viny culture!");
          $content = emailhtml( $order, $subject, $mailer );
         $headers = "Content-Type: text/html\r\n";
         //send the email through wordpress
         $mailer->send( $recipient, $subject, $content, $headers );
        }
?>

Thank you very much

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer