Jump to content

HTML Email Code Not Working


mme

Recommended Posts

Hi

 

I am trying to send an html email using php

 

Why doesnt this display it correctly?

 

<?php

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "*****@**********.com";
$Subject = "*********** - Contact";
$Name = Trim(stripslashes($_POST['Name'])); 
$Age = Trim(stripslashes($_POST['age'])); 
$Gender = Trim(stripslashes($_POST['gender'])); 
$Exp = Trim(stripslashes($_POST['experience'])); 
$Examples = Trim(stripslashes($_POST['examples'])); 
$Contact = Trim(stripslashes($_POST['contact'])); 
$Time = Trim(stripslashes($_POST['time'])); 
$Job = Trim(stripslashes($_POST['job'])); 
$Length = Trim(stripslashes($_POST['length'])); 
$Pay = Trim(stripslashes($_POST['pay'])); 
$Kind = Trim(stripslashes($_POST['kind'])); 
$Online = Trim(stripslashes($_POST['online'])); 
$HowLong = Trim(stripslashes($_POST['howlong'])); 
$EmailCheck = Trim(stripslashes($_POST['emailcheck'])); 
$PM = Trim(stripslashes($_POST['pmcheck'])); 
$Ded = Trim(stripslashes($_POST['dedication'])); 
$EmailCheck = Trim(stripslashes($_POST['emailcheck'])); 
$Skill = Trim(stripslashes($_POST['skill'])); 
$Agree = Trim(stripslashes($_POST['agree'])); 

// prepare email body text
$Body = "<html>";
$Body .= "<body>";
$Body .= "<div align='center'>";
$Body .= "<table border=\'0\' cellpadding=\'2\' cellspacing=\'2\' class=\'emailbody\'>";
$Body .= "	<tr class=\'emailbody\'>";
$Body .= "		<td class=\'emailbody\'><table width=\'600\'  border=\'0\' cellpadding=\'0\' cellspacing=\'0\'><tr> ";
$Body .= "		 				<td><img src='someimage.jpg' width='518' height='73'></td>";
$Body .= "		  </tr>";
$Body .= "	  </table></td>";
$Body .= " 		</tr>";
$Body .= " 		<tr> ";
$Body .= "    			<td>";
$Body .= "		          <h2>Member Request Form</h2>";
$Body .= "            <p> </p>";
$Body .= "	<tr> ";
$Body .= "          	<td class=\'main\'><p><em>Personal Information</em></p>";
$Body .= "          	  <p>Name: " . $Name . "<br>";
$Body .= "          	  Age: " . $Age . "<br>";
$Body .= "          	  Gender: " . $Gender . "<br>";
$Body .= "          	  Email: " . $mail . "<br>";
$Body .= "          	  Time Zone: " . $time . "<br>";
$Body .= "          	  <br>";
$Body .= "   	          </p>       	    </td>";
$Body .= "   	</tr>";
$Body .= "        	<tr height=\'14\'  class=\'main\'> ";
$Body .= "          	<td height=\'14\'><p><em>Experience</em> </p>";
$Body .= "          	  <p>Experience: " . $experience . "<br>";
$Body .= "          	    Examples: " . $Examples . "<br>";
$Body .= "       	        Position Applieing For: " . $job . "<br>";
$Body .= "   	            Length Of Contract: " . $length . "<br>";
$Body .= "       	        <br>";
$Body .= "	  </p></td>";
$Body .= "   	</tr>";
$Body .= "        	<tr class=\'main\'> ";
$Body .= "          	<td class=\'main\'><p><em>Payment</em></p>";
$Body .= "          	  <p>Are You expecpting Pay: " . $pay . "<br>";
$Body .= "          	    If So How much: " . $amount . "<br>";
$Body .= "       	        <br>";
$Body .= "          	  </p></td>";
$Body .= "   	</tr>";
$Body .= "			<tr>";
$Body .= "				<td height=\'14\' class=\"main\"><p><em>Time Online</em></p>";
$Body .= "			    <p>How Many Times Are you online per day: " . $online . "<br>";
$Body .= "			      How Long: " . $howlong . "<br>";
$Body .= "		          How often do you check your email: " . $emailcheck . "<br>";
$Body .= "	              How Often do you check your PM: " . $pmcheck . "<br>";
$Body .= "                  How much time are you willing to dedicate to your team: " . $dedication . "<br>";
$Body .= "                  Skill Rate (?/10): " . $skill . "<br>";
$Body .= "                  <br>";
$Body .= "			    </p></td>";
$Body .= "			</tr>";
$Body .= "        	<tr height=\'14\'> ";
$Body .= "          	<td height=\'14\'><p><em>Agreement</em></p>";
$Body .= "          	  <p>Agree to the terms: " . $agree . "</p>";
$Body .= "          	  <p> </p></td>";
$Body .= "        	</tr>";
$Body .= "        	<tr height=\"'4\'> ";
$Body .= "          	<td height=\'14\'><div align='center' class='style1'>© 2008 ************ - EMail Generated By ***** (MS1)</div></td>";
$Body .= "   	</tr>";
$Body .= "		</table>";
$Body .= "		</table>";
$Body .= "</div>";
$Body .= "</body>";
$Body .= "</html>";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$Email>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/96488-html-email-code-not-working/
Share on other sites

try

<?php

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "*****@**********.com";
$Subject = "*********** - Contact";
$Name = Trim(stripslashes($_POST['Name'])); 
$Age = Trim(stripslashes($_POST['age'])); 
$Gender = Trim(stripslashes($_POST['gender'])); 
$Exp = Trim(stripslashes($_POST['experience'])); 
$Examples = Trim(stripslashes($_POST['examples'])); 
$Contact = Trim(stripslashes($_POST['contact'])); 
$Time = Trim(stripslashes($_POST['time'])); 
$Job = Trim(stripslashes($_POST['job'])); 
$Length = Trim(stripslashes($_POST['length'])); 
$Pay = Trim(stripslashes($_POST['pay'])); 
$Kind = Trim(stripslashes($_POST['kind'])); 
$Online = Trim(stripslashes($_POST['online'])); 
$HowLong = Trim(stripslashes($_POST['howlong'])); 
$EmailCheck = Trim(stripslashes($_POST['emailcheck'])); 
$PM = Trim(stripslashes($_POST['pmcheck'])); 
$Ded = Trim(stripslashes($_POST['dedication'])); 
$EmailCheck = Trim(stripslashes($_POST['emailcheck'])); 
$Skill = Trim(stripslashes($_POST['skill'])); 
$Agree = Trim(stripslashes($_POST['agree'])); 

// prepare email body text
$Body = "<html>";
$Body .= "<body>";
$Body .= "<div align='center'>";
$Body .= "<table border=\'0\' cellpadding=\'2\' cellspacing=\'2\' class=\'emailbody\'>";
$Body .= "	<tr class=\'emailbody\'>";
$Body .= "		<td class=\'emailbody\'><table width=\'600\'  border=\'0\' cellpadding=\'0\' cellspacing=\'0\'><tr> ";
$Body .= "		 				<td><img src='someimage.jpg' width='518' height='73'></td>";
$Body .= "		  </tr>";
$Body .= "	  </table></td>";
$Body .= " 		</tr>";
$Body .= " 		<tr> ";
$Body .= "    			<td>";
$Body .= "		          <h2>Member Request Form</h2>";
$Body .= "            <p> </p>";
$Body .= "	<tr> ";
$Body .= "          	<td class=\'main\'><p><em>Personal Information</em></p>";
$Body .= "          	  <p>Name: " . $Name . "<br>";
$Body .= "          	  Age: " . $Age . "<br>";
$Body .= "          	  Gender: " . $Gender . "<br>";
$Body .= "          	  Email: " . $mail . "<br>";
$Body .= "          	  Time Zone: " . $time . "<br>";
$Body .= "          	  <br>";
$Body .= "   	          </p>       	    </td>";
$Body .= "   	</tr>";
$Body .= "        	<tr height=\'14\'  class=\'main\'> ";
$Body .= "          	<td height=\'14\'><p><em>Experience</em> </p>";
$Body .= "          	  <p>Experience: " . $experience . "<br>";
$Body .= "          	    Examples: " . $Examples . "<br>";
$Body .= "       	        Position Applieing For: " . $job . "<br>";
$Body .= "   	            Length Of Contract: " . $length . "<br>";
$Body .= "       	        <br>";
$Body .= "	  </p></td>";
$Body .= "   	</tr>";
$Body .= "        	<tr class=\'main\'> ";
$Body .= "          	<td class=\'main\'><p><em>Payment</em></p>";
$Body .= "          	  <p>Are You expecpting Pay: " . $pay . "<br>";
$Body .= "          	    If So How much: " . $amount . "<br>";
$Body .= "       	        <br>";
$Body .= "          	  </p></td>";
$Body .= "   	</tr>";
$Body .= "			<tr>";
$Body .= "				<td height=\'14\' class=\"main\"><p><em>Time Online</em></p>";
$Body .= "			    <p>How Many Times Are you online per day: " . $online . "<br>";
$Body .= "			      How Long: " . $howlong . "<br>";
$Body .= "		          How often do you check your email: " . $emailcheck . "<br>";
$Body .= "	              How Often do you check your PM: " . $pmcheck . "<br>";
$Body .= "                  How much time are you willing to dedicate to your team: " . $dedication . "<br>";
$Body .= "                  Skill Rate (?/10): " . $skill . "<br>";
$Body .= "                  <br>";
$Body .= "			    </p></td>";
$Body .= "			</tr>";
$Body .= "        	<tr height=\'14\'> ";
$Body .= "          	<td height=\'14\'><p><em>Agreement</em></p>";
$Body .= "          	  <p>Agree to the terms: " . $agree . "</p>";
$Body .= "          	  <p> </p></td>";
$Body .= "        	</tr>";
$Body .= "        	<tr height=\"'4\'> ";
$Body .= "          	<td height=\'14\'><div align='center' class='style1'>© 2008 ************ - EMail Generated By ***** (MS1)</div></td>";
$Body .= "   	</tr>";
$Body .= "		</table>";
$Body .= "		</table>";
$Body .= "</div>";
$Body .= "</body>";
$Body .= "</html>";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= "From: <$Email>" . "\r\n";// send email 
$success = mail($EmailTo,$Subject,$Body,$headers);

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.