How can a confirmation email be sent simultaneously to the sender when using a PHP email form?
To send a confirmation email simultaneously to the sender when using a PHP email form, you can use the "CC" header in the PHP mail() function to send a copy of the email to the sender's email address. This way, the sender will receive a confirmation email along with the email sent to the recipient.
<?php
$to = "recipient@example.com";
$subject = "Subject of the email";
$message = "This is the message content";
$headers = "From: sender@example.com\r\n";
$headers .= "Reply-To: sender@example.com\r\n";
$headers .= "CC: sender@example.com\r\n";
mail($to, $subject, $message, $headers);
?>
Keywords
Related Questions
- How can splitting code into separate files and including them impact the behavior of references and variable inheritance in PHP?
- What are the potential pitfalls of using the setTo method in a foreach loop with Swift Mailer?
- How can PHP developers efficiently compare dates and times, such as calculating the difference between registration dates and current dates for user notifications?