Jump to content

Using the php mail() function


ChristianToney

Recommended Posts

I recently decided to have the data from the forms that were filled out not only emailed to me but to the person filling the form out for conf. When the form is finished and the person hits submit every comes up with the success and the data gets logged on the server but the emails never send out. Any help is much appreciated.

 

Here is the code:

 

<?php
$name = $_POST["First"];
$Last_name = $_POST["Last"];
$Age = $_POST["Age"];
$Height = $_POST["Height"];
$Weight = $_POST["Weight"];
$Eye_Color = $_POST["Eye"];
$Hair = $_POST["Hair"];
$Glasses_or_Contacts = $_POST["Glasses_or_Contacts"];
$Customer_Email = $_POST["Contact_Email"];
$email_from ='WEBMASTEREMAIL@gmail.com';
$email_subject = "Form completion Email";
$email_body = $name . $Last_name . $Age . $Height . $Weight $Eye_Color . $Hair . $Glasses_or_Contacts . $Customer_Email;
$to = 'CUSTOMEREMAIL@gmail.com, WEBMASTEREMAIL@gmail.com';
$headers = "From: $email_from rn";
if(!mail($to,$email_subject,$email_body)) {
echo 'failed';
} else {
echo 'sent';
}
?>
All emails were replaced in caps. btw
And yes I have checked spam and still nothing is sent.
Link to comment
Share on other sites

what errors are you getting?

 

EDIT:

 

worked for me:

<?php$name = "niche";$email_from ='niche@xyz.com';$email_subject = "Form completion Email";$email_body = $name; $to = 'niche@xyz.com';$headers = "From: $email_from rn"; if(!mail($to,$email_subject,$email_body)) {    echo 'failed';} else {    echo 'sent';}?>
Edited by niche
Link to comment
Share on other sites

This is the correct format for send mail in PHP

<?php   $to='example@gmail.com';            $subject='Send mail using php';   $message='This mail send using php';   $headers='From: guruparthiban19@gmail.com';   $mail=mail($to,$subject,$message,$headers);   if($mail)   {    echo'Mail send successfully';   }   else   {    echo'Mail is not send';   } ?>

Your email address may be wrong. The email id should be lowercase. It may be cause errors.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...