I have now moved to using Pear Mailing rather than just php mail i cannot see where Ive gone wrong it doesnt send any e-mails.
PHP Script:
[php]<?php
if(isset($_POST[‘eadd’])) {
require_once “PEAR/Mail.php”;
$email_to = "[email protected]";
$email_subject = “Registration Request”;
$host = “184.70.113.194”;
$username = "[email protected]";
$from_address = "[email protected]";
$password = “*******”;
$reply_to = "[email protected]";
$port = “587”;
function died($error) {
// your error code can go here
echo “We are very sorry, but there were error(s) found with the form you submitted. “;
echo “These errors appear below.
”;
echo $error.”
”;
echo “Please go back and fix these errors.
”;
die();
}
// Validate expected data exists
if(!isset($_POST[‘name’]) || !isset($_POST[‘eadd’]) || !isset($_POST[‘club_name’]) || !isset($_POST[‘province’]) || !isset($_POST[‘comments’])) {
died(‘We are sorry, but there appears to be a problem with the form you submitted.’);
}
$name = $_POST[‘name’]; // required
$eadd = $_POST[‘eadd’]; // required
$club_name = $_POST[‘club_name’]; // not required
$town = $_POST[‘town’]; // required
$province = $_POST[‘province’]; // not required
$pcode = $_POST[‘pcode’]; // not required
$phone = $_POST[‘phone’]; // not required
$shoottime = $_POST[‘shoottime’]; // not required
$class = $_POST[‘class’]; // not required
$event = $_POST[‘event’]; // not required
$comments = $POST[‘comments’]; // required
$error_message = “”;
$email_exp = '/^[A-Za-z0-9.%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/’;
if(!preg_match($email_exp,$eadd)) {
$error_message .= ‘The Email Address you entered does not appear to be valid.
’;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if(!preg_match($string_exp,$name)) {
$error_message .= ‘The Name you entered does not appear to be valid.
’;
}
if(strlen($comments) < 1)
$error_message .= ‘The Comments you entered do not appear to be valid.
’;
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = “Registraion details below.\n\n”;
function clean_string($string) {
$bad = array(“content-type”,“bcc:”,“to:”,“cc:”,“href”);
return str_replace($bad,"",$string);
}
$email_message .= “Name: “.clean_string($name).”\n”;
$email_message .= “E-Mail Address: “.clean_string($eadd).”\n”;
$email_message .= “Club Name: “.clean_string($club_name).”\n”;
$email_message .= “Town / City: “.clean_string($town).”\n”;
$email_message .= “Province: “.clean_string($province).”\n”;
$email_message .= “Postal Code: “.clean_string($pcode).”\n”;
$email_message .= “Phone Number: “.clean_string($phone).”\n”;
$email_message .= “Shoot Time: “.clean_string($shoottime).”\n”;
$email_message .= “Class: “.clean_string($class).”\n”;
$email_message .= “Event: “.clean_string($event).”\n”;
$email_message .= “Comments: “.clean_string($comments).”\n”;
// This section creates the email headers
$auth = array(‘host’ => $host, ‘auth’ => true, ‘username’ => $username, ‘password’ => $password);
$headers = array(‘From’ => $from_address, ‘To’ => $email_to, ‘Subject’ => $email_subject, ‘Reply-To’ => $reply_to);
// This section send the email
$smtp = Mail::factory(‘smtp’, $auth);
$mail = $smtp->send($email_to, $headers, $email_message);
if (PEAR::isError($mail)) {?>
Unfortunately, the message could not be sent at this time. Please try again later.
<?php } else { ?>
Thank you for contacting us. We will be in touch with you very soon.
<?php } } ?>[/php]
Web Form Code:
[code]
Stavely Archery Lanes Event Registration
.style1 {
text-align: center;
color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
}
.style2 {
font-family: Arial, Helvetica, sans-serif;
font-size: x-large;
color: #FFFFFF;
}
Stavely Archery Lanes Event Registration
Name:
E-mail Address:
Club Name & #
City/Town:
Province:
Postal Code:
Phone Number:
Shoot Time:
9:00 AM
10:15 AM
11:30 AM
9:00 AM or 11:30 AM or 10:15 AM
Class
M60 Male
M60 Female
M50 Male
M50 Female
BHO Male
BHO Female
BHR Male
BHR Female
BHF Male
BHF Female
JRC Male
JRC Female
CADC Male
CADC Female
HUN Male
HUN Female
HF Male
HF Female
M50TR Male
M50TR Female
BB Male
BB Female
TRD Male
TRD Female
IN Male
IN Female
JRT Male
JRT Female
CADT Male
CADT Female
CUBT Male
CUBT Female
PCUBT Male
PCUBT Female
CUBC Male
CUBC Female
PCUBC Male
PCUBC Female
Event:
Stavely Archery Lanes Doug Symonds 3D Memorial Shoot
Stavely Archery Lanes Annual 3D Indoor Tournament March 15th 2014
Stavely Archery Lanes 3D Outdoor Spring Shoot May 17th,18th,19th 2014
Other Information:
[/code]
Any help would be hugely appreciated!!! Merry Christmas thanks a million!