" . "\r\n"; $headers .= "Reply-To: $sender_email" . "\r\n"; // Additional headers to improve deliverability $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; // Convert newlines to HTML line breaks for email body $html_body = nl2br($body); // Send email $mail_sent = mail($recipient, $subject, $html_body, $headers); if ($mail_sent) { $success_message = "Email sent successfully to $recipient!"; // Clear form fields on success $sender_name = $sender_email = $recipient = $subject = $body = ''; } else { $errors[] = "Failed to send email. Please check your PHP mail configuration."; } } } ?>
Send professional emails directly from your PHP application