How can the mail() function be used to send a complete data output instead of sending each output individually?

To send a complete data output using the mail() function in PHP, you can concatenate all the individual outputs into a single variable before sending the email. This way, the entire data output will be included in the body of the email message.

// Concatenate all individual outputs into a single variable
$output = "Output 1: " . $output1 . "\n";
$output .= "Output 2: " . $output2 . "\n";
$output .= "Output 3: " . $output3 . "\n";

// Send email with complete data output
$to = "recipient@example.com";
$subject = "Complete Data Output";
$headers = "From: sender@example.com";
mail($to, $subject, $output, $headers);