开发者

PHP mail form not getting fields from html

I am working on a website and I am having trouble getting a PHP mail script to send the contents of my form to an email. It is for the registration of students for a club. The link where you can view the current form is http://trhs-snowriders.com/register.htm and I would appreciate any help from anyone with experience with mail scrips and making sure they get delivered. I own the server so I can make any tweaks that may be necessary

The Mail is being sent but is usually in the spam folder. The other problem I am having is the php script is not getting the values from the html form... Here is the html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"> 

<html> 
<head> 
<title>Timberlane Snowriders Registration</title> 


<META http-equiv="last-modified" content="Module 3-1, 2010-12-16"/> 

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"/> 
<!--Begin Custom JavaScript Form Validator--> 
<script type="text/javascript"> 
function valbutton(thisform)
{
var l=document.forms["registrationForm"]["lastName"].value;
var f=document.forms["registrationForm"]["firstName"].value;
if (l==null || l=="")
{
alert("Last Name must be filled out!");
return false;
}
if (f==null || f=="")
{
alert("First Name must be filled out!");
return false;
}
if (document.registrationForm.level.selectedIndex==0)
{
alert("Please select your Skiing/Boarding ability!");
document.registrationForm.level.focus();
return false;
}
myOption = -1;
for (i=thisform.emergency.length-1; i > -1; i--) {
if (thisform.emergency[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select Yes or No");
return false;
}
myOption2 = -1;
for (i=thisform.consent.length-1; i > -1; i--) {
if (thisform.consent[i].checked) {
myOption2 = i; i = -1;
}
}
if (myOption2 == -1) {
alert("You must select Yes or No");
return false;
}
myOption3 = -1;
for (i=thisform.procedure.length-1; i > -1; i--) {
if (thisform.procedure[i].checked) {
myOption3 = i; i = -1;
}
}
if (myOption3 == -1) {
alert("You must select Yes or No");
return false;
}
thisform.submit();
}
</script> 
<!--End custom JavaScript Form Validator--> 
<SCRIPT LANGUAGE="JavaScript"> 

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

image1 = new Image();
image1.src=images/return_dark.gif;

image3 = new Image();
image3.src=images/prices_dark.gif;

image4 = new Image();
image4.src=images/members_dark.gif;

image5 = new Image();
image5.src=images/gallery_dark.gif;

image6 = new Image();
image6.src=images/fitness_dark.gif;

image7 = new Image();
image7.src=images/contact_dark.gif;

image8 = new Image();
image8.src=images/calendar_dark.gif;

image9 = new Image();
image9.src =images/emergency_dark.gif;

// End -->
</script> 

</head> 

<body background="images/silver-diamond-plate.jpg" link="black" vlink="blue" alink="red"     marginheight="0" marginwidth="0" topmargin="0" bottommargin="0"> 
<table border="0" cellspacing="0" cellpadding="0"> 
<tr><td width="1280" height="768"> 
<table align="center" width="1280" height="768" border="0" cellpadding="1"     cellspacing="2" align="left"> 
<tr> 
<td rowspan="10" width="250" height="760" align="center" valign="top"     background="images/pats_sidebar.jpg" title="Night view of Pat's Peak"> 

<a href="index.htm" onmouseover="image1.src='images/return_dark.gif';"     onmouseout="image1.src='images/return.gif';"> 
<img name="image1" src="images/return.gif" border="0"/ title="Return to Snowriders"></a> 

<a href="register.htm" onmouseover="image2.src='images/registration_dark.gif';"     onmouseout="image2.src='images/registration.gif';"> 
<img name="image2" src="images/registration.gif" border="0"/ title="Registration"></a> 

<a href="prices.htm" onmouseover="image3.src='images/prices_dark.gif';" onmouseout="image3.src='images/prices.gif';"> 
<img name="image3" src="images/prices.gif" border="0"/ title="2010 Prices"></a> 

<a href="members.htm" onmouseover="image4.src='images/members_dark.gif';" onmouseout="image4.src='images/members.gif';"> 
<img name="image4" src="images/members.gif" border="0"/ title="Members"></a> 

<a href="gallery.htm" onmouseover="image5.src='images/gallery_dark.gif';" onmouseout="image5.src='images/gallery.gif';"> 
<img name="image5" src="images/gallery.gif" border="0"/ title="Photo Gallery"></a> 

<a href="fitness.htm" onmouseover="image6.src='images/fitness_dark.gif';" onmouseout="image6.src='images/fitness.gif';"> 
<img name="image6" src="images/fitness.gif" border="0"/ title="Getting in Shape"></a> 

<a href="contact.htm" onmouseover="image7.src='images/contact_dark.gif';" onmouseout="image7.src='images/contact.gif';"> 
<img name="image7" src="images/contact.gif" border="0"/ title="Contact Us"></a> 

<a href="calendar.htm" onmouseover="image8.src='images/calendar_dark.gif';"     onmouseout="image8.src='images/calendar.gif';"> 
<img name="image8" src="images/calendar.gif" border="0"/ title="Contact Us"></a> 

<a href="faq.htm" onmouseover="image9.src='images/question_dark.gif';"     onmouseout="image9.src='images/question.gif';"> 
<img name="image9" src="images/question.gif" border="0"/ title="Frequently Asked      Questions"></a> 

<a href="emergency.htm" onmouseover="image10.src='images/emergency_dark.gif';"  onmouseout="image10.src='images/emergency.gif';"> 
<img name="image10" src="images/emergency.gif" border="0"/ title="Emergency"></a> 

</tr></td> 
<tr> 
<td colspan="2" width="1030" height=226 rowspan="1" colspan="1" align="center"    valign="top">  
<img src="images/registration.jpg" title="Snowriders main banner"</td> 
<tr> 

<td bgcolor=silver colspan="2" width="1030" height="100" align="center" valign="middle"> 
<font face="arial" color=red size="6"><b>Status:</b></font></p> 
<font face="arial" color=navy size="5"><b>We are currently registering members for 2011-    2012.<br/>Check the <a href="members.htm">members listing</a> here:</b></p></font> 
</td> 
</tr> 

<td background="images/opacity1.JPG" colspan="2" width="1030" height="300" rowspan="1"     colspan="1" align="left" valign="top"><font face="Comic Sans MS" size=7 color=black></p>   <center>Registration is first-come, first-served.<br/>Complete the following SIX steps:    </center></p></font> 

<font face="Comic Sans MS" size=6 color=black> 

<blockquote><ol type="decimal" start="1"> 
<li>Print and fill out the <a href="forms/contact_form.pdf" target="_blank">"Emergency     Contact Form."</a></li> 
<li>Read the <a href="forms/warning_consent.pdf" target="_blank">"Warning and Consent Agreement."</a></li> 
<li>Read the <a href="forms/prices_procedures.pdf" target="_blank">"Prices and Procedures sheet."</a></li> 
<li>Fill in and submit the following form:<br/> 
(This form will generate an e-mail, that will automatically be sent)</p></li> 
</ol></blockquote> 
</font></td> 
 </tr> 
<td colspan="2" width="100%" rowspan="1" align="center" valign="top"> 

<form name="registrationForm" action="form2email.php" method="post" enctype="text/plain"> 
<input type="hidden" name="email" value="formsender@trhs-snowriders.com" /> 
<input type="hidden" name="redirect" value="http://trhs-       snowriders.com/registercomplete.html#regcom" /> 
<center> 
<table border="2" cellpadding="3" cellspacing="2" bgcolor="gray"> 
<tr> 
   <td align="right"><font face="Comic Sans MS" size="4"><b>Student's Last Name:</b></font>         <input type="text" name="lastName" align="left" size="50"/></td> 
</tr> 
<tr> 
    <td align="right"><font face="Comic Sans MS" size="4"><b>Student's First Name:</b>       <font> <input type="text" name="firstName" align="left" size="50"/></td> 
</tr> 
<tr> 
<td align="right"><font face="Comic Sans MS" size="4"><b>Mother's Last Name (if different)</b></font> <input type="text" name="mother" align="left" size="50"/></td> 
</tr> 
<tr> 
<td align="right"><font face="Comic Sans MS" size="4"><b>Father's Last Name (if different)</b></font> <input type="text" name="father" align="left" size="50"/></td> 
</tr> 
<tr> 
<td align="right"><font face="Comic Sans MS" size="4"><b>What is your skiing/boarding   ability?</b></font> 
<select name="level"> 
<option selected> (please choose)</option> 
<option>I've never skied/boarded before</option> 
<option>I've had a few lessons and I can stop and turn</option> 
<option>I can ski/board on easy slopes</option> 
<option>I can ski/board on more challenging slopes</option> 
<option>I can do it all!!</option> 
</select> 
</tr> 
<tr> 
<td align="right" ><font face="Comic Sans MS" size="4"><b>I have filled in, printed, and     signed the "Emergency Contact" form.</b></font> 
<input type="radio" name="emergency" value="Yes" /> Yes
<input type="radio" name="emergency" value="No" />No 
</tr> 
<tr> 
<td align="right" ><font face="Comic Sans MS" size="4"><b>I have read and understand the   "Warning and Consent Agreement."</b></font> 
<input type="radio" name="consent" value="Yes" /> Yes
<input type="radio" name="consent" value="No" />No 
</tr> 
<tr> 
<td align="right" ><font face="Comic Sans MS" size="4"><b>I have read and understand the   "Prices and Procedures Sheet."</b></font> 
<input type="radio" name="procedure" value="Yes" /> Yes
<input type="radio" name="procedure" value="No" />No 
</tr> 
<tr> 
<td col span="2" align="center"><font face="Comic Sans MS" size="4"> 
<b>Is there something I need to know that isn't included in this form?</b></font> 
<br> 
<textarea name="extrastuff" rows="5" cols="60"></textarea></td></tr> 
<tr><td colspan="2"> 
<center><input type="SUBMIT" value="Submit" onclick="valbutton(registrationForm);return false;" /></center> 
</td></tr> 
</table></form> 
</td> 
</tr> 

<td background="images/opacity1.JPG" colspan="2" width="1030" height="300" rowspan="1"    colspan="1" align="left" valign="top"><font face="Comic Sans MS" size=6 color=black></p>Once    you have submitted the form online, please do the following:</p> 
<blockquote><ol type="decimal" start="5"> 
<li>Write a check for $50 to <i><b>"Timberlane" or "TRHS"</b></i></p> 
This check is <u>NON-REFUNDABLE</u> unless the bus is filled and we can replace your      seat with someone from the waiting list.</p></li> 
<li>Have your student bring the printed "Emergency Contact Form" and the signed check to     Mr. Rugoletti in Room 114 or place it in his mailbox in the front office.</p> 
Forms and checks may also be mailed to:
<blockquote><blockquote><blockquote><blockquote><blockquote> 
&nbsp;Timberlane Regional High School<br/> 
&nbsp;C/O Steven Rugoletti<br/> 
&nbsp;36 Greenough Road<br/> 
&nbsp;Plaistow, NH  03865
</blockquote> 
</ol> 
<font face="Comic Sans MS" size="4" color=navy>Snowriders is a Timberlane Regional High     School sponsored activity.  The National Ski Patrol <a     href="http://www.nsp.org/slopesaftey/respcode.aspx" target="_blank">"Resonsibility Code,"    </a> in addition to school rules and polices, available in the Timberlane <a     href="http://www.timberlanehs.com/handbook.pdf" target="_blank">student handbook</a>, will     be in effect at all times.  Failure to abide by these policies may result in loss of time on     the slopes, removal of one's lift ticket, suspension from the group, and possibly removal     from the group.
</font></td> 
</tr> 
</table> 
<font face="Times New Roman" size="4" color=black><b> 
<SCRIPT 
LANGUAGE="JavaScript"> 
<!-- Javascripts resource by Hypergurl!! 
http://www.hypergurl.com --> 
<!-- hide script begin 
var m = "Page updated  " + document.lastModified; 
var p = m.length-8; document.writeln("<center>"); 
document.write(m.substring(p, 0)); 
document.writeln("</center>"); 
// End --> </SCRIPT> 
</b></font> 
</td></tr></table> 
</body> 
</html>

And here is the processReg.php file

<?php
//change settings here
$your_email = "formsender@trhs-snowriders.com";
$your_smtp = "mail.trhs-snowriders.com";
$your_smtp_user = "formsender+trhs-snowriders.com";
$your_smtp_pass = "passwordhere";
$your_website = "http://trhs-snowriders.com";


require("phpmailer/class.phpmailer.php");


//get contact form details
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$url = 'registercomplete.html#regcom';

//start phpmailer code 

$ip = $_SERVER["REMOTE_ADDR"];
$user_agent = $_SERVER['HTTP_USER_AGENT'];

$response = "Date: " . date("d F, Y h:i:s A",time()+ 16 * 3600 - 600);
$response .= "IP Address: " . $ip;
$response .= "User-agent:" . $user_agent;
$response .= "----------------------";
$response .= "\n\n";
$response .= "Last Name: " . $_REQUEST["lastName"] . "\n";
$response .= "First Name: " . $_REQUEST["firstName"] . "\n";
$response .= "Mothers Last Name: " . $_REQUEST["mother"] . "\n";
$response .= "Fathers Last Name: " . $_REQUEST["father"] . "\n";
$response .= "Riding Ability: " . $_REQUEST["level"] . "\n";
$response .= "Emergency: " . $_REQUEST["emergency"] . "\n";
$response .= "Consent: " . $_REQUEST["consent"] . "\n";
$response .= "Procedure: " . $_REQUEST["procedure"] . "\n";
$response .= "Extra Stuff: \n";
$response .= $_REQUEST["extrastuff"];

$mail = new PHPmailer();
$mail->SetLanguage("en", "phpmailer/language");
$mail->From = $your_email;
$mail->FromName = $your_website;
$mail->Host = $your_smtp;
$mail->Mailer   = "smtp";
$mail->Password = $your_smtp_pass;
$mail->Username = $your_smtp_user;
$mail->Subject = "New Snowriders Registration";
$mail->SMTPAuth  =  "true";

$mail->Body 开发者_运维问答= $response;
$mail->AddAddress($your_email,"$your_website");
$mail->AddReplyTo($email,$name);


if (!$mail->Send()) {
echo "<p>There was an error in sending mail, please try again at a later time</p>";
echo "<p>".$mail->ErrorInfo."</p>";
} else {
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
}

$mail->ClearAddresses();
$mail->ClearAttachments();

?>

Thanks in advance for all help that can be contributed.


You can't do anything in your script to solve this. In this day and age, you need a properly configured mailserver. This entails implementing (at least) the following correctly:

  • Proper reverse DNS entry for the mail server
  • SPF
  • Domainkeys & DKIM

Also make sure that the mailserver disables open relay, isn't listed in any of the DNSBLs and doesn't host any "spamming" lists. Once your mailserver is configured correctly, it'll take a few days (weeks?) for the major email providers to realize that you aren't an evil spammer.

OTOH, if the mailserver config isn't in your hands, move to a setup that has all these.


Your mail script isnt the problem unless it is not sending it at all. what you should check is the IP address it is sending it from. there are alot of IP addresses that have been blacklisted. therefore they treat your email as spam.

Check here-> http://network-tools.com/default.asp?prog=sbl

or here-> http://whatismyipaddress.com/blacklist-check


As said above, change the headers you send with the email. You may have to set it as your website. By default it could be something random like

s12290318823-host112390823@host.com

this will definitely get your mail sent into the spam folder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜