How can PHP developers create a confirmation email to be sent upon form submission?
To create a confirmation email to be sent upon form submission, PHP developers can use the PHP mail() function to send an email to the user with a confirmation message. This function allows developers to specify the recipient email address, subject, message body, and additional headers such as From, Cc, and Bcc.
<?php
// Define the recipient email address
$to = "recipient@example.com";
// Define the subject of the email
$subject = "Confirmation Email";
// Define the message body
$message = "Thank you for submitting the form. Your submission has been received.";
// Define additional headers
$headers = "From: sender@example.com\r\n";
$headers .= "Reply-To: sender@example.com\r\n";
$headers .= "CC: cc@example.com\r\n";
// Send the email
mail($to, $subject, $message, $headers);
?>
Related Questions
- What are the potential pitfalls of converting relative links to absolute links in PHP scripts?
- What role does jQuery play in simplifying the process of executing shell commands through PHP on a website?
- How can data from external sources be properly processed and converted to the correct charset in PHP applications?