How can PHP be utilized to handle form submissions and send emails to multiple recipients without exposing all email addresses?
To handle form submissions and send emails to multiple recipients without exposing all email addresses, you can use the BCC (Blind Carbon Copy) feature in PHP's mail function. By adding all the email addresses to the BCC header, the recipients will not see each other's email addresses. This helps maintain the privacy of the recipients.
<?php
$to = 'recipient1@example.com, recipient2@example.com'; // main recipient
$subject = 'Subject of the email';
$message = 'Body of the email';
$headers = 'From: sender@example.com' . "\r\n";
$headers .= 'Bcc: recipient3@example.com, recipient4@example.com' . "\r\n";
mail($to, $subject, $message, $headers);
?>
Keywords
Related Questions
- How can the use of nested sets or XML data structures improve the efficiency and readability of PHP code for menu generation?
- How can PHP developers ensure proper handling of file operations to prevent errors or data corruption?
- How can the mktime function be used to convert a date to a timestamp in PHP?