Swayamjit Posted January 6, 2023 Share Posted January 6, 2023 <?php $name = $_POST['name']; $email = $_POST['email']; $contact = $_POST['contact']; $subject = $_POST['subject']; $message = $_POST['message']; ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); $to = "xyz@gmail.com"; $subject = "Enquiry Through Website"; $headers = 'From: XYZ <info@xyz.com>' . PHP_EOL . 'Reply-To: XYZ <info@xyz.com>' . PHP_EOL . 'X-Mailer: PHP/' . phpversion(); $email_body = "Full Name: " . $name . "\r\n" . "Email ID: " . $email . "\r\n" . "Contact Number: " . $contact . "\r\n" . "Subject: " . $subject . "\r\n" . "Message: " . $message ; mail($to,$subject,$email_body, $headers); header("Location:thankyou.html"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/315765-php-mail-function-not-delivering-html-form-contents-to-my-mail-id/ Share on other sites More sharing options...
phppup Posted January 6, 2023 Share Posted January 6, 2023 You did not ask a question. You didn't post your code within the designated coding < > template. Nonetheless, it appears your mail function mail($to,$subject,$email_body, $headers); is directing your outbound emails to the variable $to (which appears to be equated to xyz@gmail.com) Either check the inbox of xyz@gmail.com or change the email address connected to $to Quote Link to comment https://forums.phpfreaks.com/topic/315765-php-mail-function-not-delivering-html-form-contents-to-my-mail-id/#findComment-1604313 Share on other sites More sharing options...
ginerjm Posted January 6, 2023 Share Posted January 6, 2023 (edited) Have to ask - Have you sent mail this way previously? PS - I would move the error checking settings to the top of your script. That way you will perhaps see some new errors that you missed by doing the settings late. And this is a bit easier way to provide your body content: $email_body = " Full Name: $name/r/n Email ID: $email/r/n Contact Number: $contact\r\n Subject: $subject\r\n Message: $message"; $email_body = " Full Name: $name\r\n Email ID: $email\r\n Contact Number: $contact\r\n Subject: $subject\r\n Message: $message"; Edited January 6, 2023 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/315765-php-mail-function-not-delivering-html-form-contents-to-my-mail-id/#findComment-1604314 Share on other sites More sharing options...
ginerjm Posted January 6, 2023 Share Posted January 6, 2023 And something else I just remembered. I do believe that if you are running a script that you must use a valid domain address as your 'From' one. You can't use abc.com as the From if you are using xyz.com as your hostname. Quote Link to comment https://forums.phpfreaks.com/topic/315765-php-mail-function-not-delivering-html-form-contents-to-my-mail-id/#findComment-1604317 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.