Generate and send ICS file through WordPress

This is untested, but it’s kind of the approach you need to take. I’m just dealing with the last method in your class.

Here’s how I would approach it:

  1. You need to specify a file path when you save the file so you can use that later to get the file to attach.
  2. Set up the values for your email (the “to” address, subject, message, headers, and path to the attachment).
  3. Use the variables from #2 for wp_mail() to send your message.

Here’s the function from your class with my additions:

public function send_booking_request(){
    if(! ( $this->has_valid_nonce() ) ){
      return;
    }
    $fname = $_POST['client_fname'];
    $lname = $_POST['client_lname'];
    $phone = $_POS['client_phone'];
    $email = $_POST['client_email'];

    $title="Prenotazione";

    $description = $fname . $lname . $phone . $email;


    $ics = new WP_ICS(array(
      'location' => '',
      'description' => $description,
      'dtstart' => $_POST['client_checkin'],
      'dtend' => $_POST['client_checkout'],
      'summary' => '',
      'url' => ''
    ));


    // You need to specify the path here so you can use it later to get the attachment
    $uploads = wp_upload_dir();
    $path = $uploads['path'];

    file_put_contents( $path . '/reservation.ics', $ics->to_string() );

    // Set up email
    $to = '[email protected]';
    $subject = "reservation file";
    $message = "Please see attached reservation.";
    $headers="From: My Name <[email protected]>" . "\r\n";
    $attachments = array( $path . '/reservation.ics' );

    // Send the email.
    wp_mail( $to, $subject, $message, $headers, $attachments );

    #header('Content-Type: text/calendar; charset=utf-8');
    #header('Content-Disposition: attachment; filename=reservation.ics');

}

Assuming the rest of your code is OK and the file is created, this should be able to get it and attach it to an email.