Question

I hope someone can help me out with this problem I'm facing.

I have a simple PHP form which is showing an error I don't know why, here's the code:

        <?php

// Get values from form
$name=$_POST['name'];
$email=$_POST['email'];
$emailconfirmation=$_POST['emailconfirmation'];
$phone=$_POST['phone'];
$address=$_POST['address'];
$postcode=$_POST['postcode'];
$eventarea=$_POST['eventarea'];
$typeevent=$_POST['typeevent'];
$eventdate=$_POST['eventdate'];
$guestnumber=$_POST['guestnumber'];
$extraguests=$_POST['extraguests'];
$siteformarquee=$_POST['siteformarquee'];
$seatedorstanding=$_POST['seatedorstanding'];
$dancefloor=$_POST['dancefloor'];
$servicetent=$_POST['servicetent'];
$surfacemarquee=$_POST['surfacemarquee'];
$details=$_POST['details'];
$town=$_POST['town'];




$to = "email@email.com, email2@email.com";
$subject = "Quote to review from Elite Marquees";
$message = " Name: " . $name . "\r\n Town of the Event: " . $town . "\r\n Telephone Number: " . $phone . "\r\n Email: " . $email . "\r\n Confirm Email Address: " . $emailconfirmation . "\r\n Address: " . $address . "\r\n Post Code: " . $postcode . "\r\n The area where your event will take place: " . $eventarea . "\r\n Type of the Event: " . $typeevent . "\r\n Date of the Event: " . $eventdate . "\r\n Number of Guests: " . $guestnumber . "\r\n If a wedding how many extra guests for the evening?: " . $extraguests . "\r\n Town Where the Event will take place: " . $town . "\r\n Do you have a venue or site for the marquee?: " . $siteformarquee . "\r\n Will your guests be seated or standing?: " . $seatedorstanding . "\r\n Do you require a dance floor?: " . $dancefloor . "\r\n Do you require a service tent?: " . $servicetent . "\r\n Type of surface the marquee will be erected on?: " . $surfacemarquee . "\r\n Details or Questions?: " . $details;


/*$from = "Elite Marquees";*/
$headers = "From: Elite Marquees <info@elitemarquees.com>" . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n"; 

if(@mail($to,$subject,$message,$headers))
{
  print "<script>document.location.href='http://elite-marquees.co.uk/success.html';</script>";

}else{
  echo "Error! Please try again.";
}



?>

Live Form

Can someone please help me out?

Thanks!

Was it helpful?

Solution

the email you're using as FROM must be on the same server as the website, meaning info@elite-marquees.co.uk would work just fine but not info@elitemarquees.com

try adding a fifth parameter to your mail() command:

mail($to,$subject,$message,$headers,"-f info@elitemarquees.com");

OTHER TIPS

Which error are you getting? And is your php.ini updated for the following lines?

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = Your Email ID

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail

Php's Mail Function Return Values:

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

Essentially, you mail function is failing.

First, check if you can send a test mail on the server. If you can't the server settings are not configured to use email.

Try and call a really simple, hard-coded mail().

If it is still failing, then it's 99% your server set up. Check your php.ini settings, and make sure your server can support sending out emails.

Firstly remove the @ before the mail function . After try again if error occur again and again you must check whats the value are comes for you can use for that var_dump(mail(your mail)) or die; function to check the value if it give the null that means something is missing. Then again check var_dump for other values you will soon find the error May be that help you .

The problem was from <info@elitemarquees.com> I changed it to <info@elitemarquees.co.uk> and now it's working.

Thanks to all of you guys! You rock!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top