Basic PHP Contact Form

I just want to implement a very simple contact form in my site but the code I acquired does not send the email. Please find the code below:

<?php $userName = $_POST['cf_name']; $userSubject = $_POST['cf_subject']; $userEmail = $_POST['cf_email']; $userMessage = $_POST['cf_message']; $to = "carryud2@gmail.com"; $subject = "Email from my website"; $body = "Information Submitted:"; $body .= "\r\n Name: " . $userName; $body .= "\r\n Order: " . $userSubject; $body .= "\r\n Email: " . $userEmail; $body .= "\r\n Message: " . $userMessage; mail($to, $subject, $body); ?>

Use some library like PHPMailer or SwiftMailer that provides more detailed error messages.

I assume you enabled “php mail” in your .ini?

Sponsor our Newsletter | Privacy Policy | Terms of Service