Jump to content

PHP mail() function not delivering html form contents to my mail id


Swayamjit

Recommended Posts

<?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");
     
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by ginerjm
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.