I implemented this http://www.websitecodetutorials.com/code/jquery-plugins/jquery-ajaxsubmit.php tutorial on my form, and the form works successfully and displays the thank you div on submission. But the problem is I don't receieve any email, seems like PHP mailer is not working.
Please see the code below
<?php
// Insert your email/web addresses and correct paths
$mailto = 'adil@adilsaleem.co.uk' ;
$from = "web@city.com" ;
$formurl = "http://astonstorlin.co.uk/citycoaches3/formmail.php" ;
$errorurl = "http://astonstorlin.co.uk/citycoaches3/error.php" ;
$thankyouurl = "http://astonstorlin.co.uk/citycoaches3/thankyou.php" ;
// Place Your Form info here...
$pickuppoint = ($_POST['pickuppoint']);
$destination = ($_POST['destination']);
// Check If Empty
// Add more Validation/Cleaning here...
// Place your Corresponding info here...
$message =
"Pick Point: $pickuppoint\n\n" .
"Destination: $destination\n\n" .
"noppl: $noppl\n\n"
;
// Leave Alone
mail($mailto, $from, $message,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep );
header( "Location: $thankyouurl" );
exit ;
?>
I think your headers are not working. $headersep is not defined and moreover please follow :
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($to, $subject, $message, $headers);
Example copied from http://php.net/manual/en/function.mail.php you can refer for more reading this link.
If you are on a shared hosting for example, sometimes they require you to use a fifth parameter like additional_parameters.
mail('nobody@example.com', 'the subject', 'the message', null,'-fwebmaster@example.com');
Check example 3 here: http://php.net/manual/en/function.mail.php
Thank you very much for all your help people, much appreciated.
I got the script working by deleting
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep );
And the script started working. I have tried using other HTML php mailer but them don't seem to work with this tutorial example for some reason. http://www.websitecodetutorials.com/code/jquery-plugins/jquery-ajaxsubmit.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.