Bcc mail full ofrm
You're referring to the "Bcc" (Blind Carbon Copy) field in email forms!
The Bcc field is used to send a copy of an email to a list of recipients without including their email addresses in the "To" or "CC" fields. This is useful when you want to send an email to a large number of people without revealing their email addresses to each other.
Here's an example of how you can use the Bcc field in an email form:
HTML Form Code:
<form action="send-email.php" method="post">
<label for="subject">Subject:</label>
<input type="text" id="subject" name="subject"><br><br>
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea><br><br>
<label for="bcc">Bcc (optional):</label>
<input type="email" id="bcc" name="bcc" multiple><br><br>
<input type="submit" value="Send Email">
</form>
PHP Code (send-email.php):
<?php
// Check if the form has been submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form data
$subject = $_POST["subject"];
$message = $_POST["message"];
$bcc = $_POST["bcc"];
// Send the email
$to = "[email protected]"; // Replace with the recipient's email address
$headers = "From: Your Name <[email protected]>";
$headers.= "\r\nBcc: ". implode(", ", $bcc);
mail($to, $subject, $message, $headers);
// Display a success message
echo "Email sent successfully!";
}
?>
In this example, the Bcc field is an HTML input field with the multiple
attribute set to true
, allowing the user to enter multiple email addresses separated by commas. The PHP code then uses the implode
function to concatenate the Bcc email addresses into a single string, which is then used in the mail
function to send the email.
Remember to replace the [email protected]
and [email protected]
placeholders with your actual email addresses.