0

I was working on a simple contact form and after submit button is click it redirects to the thank you page which worked perfectly and received the email from the form. Right now, somehow it doesnt send email anymore. I dont know what I did that messed up the code.

PHP

<?php 
$toemail = "cluneborg@hotmail.com"; 
$subject = "New Agent Inquries"; 
$full_name = $_POST['full_name']; 
$email = $_POST['email']; 
$agent_type = $_POST['agent_type'];

if($_SERVER['REQUEST_METHOD']=="POST") {    

$full_name=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['full_name']));  
$email=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['email']));  
$agent_type=str_replace ( array("\n"), array("   <br>"),trim($_REQUEST['agent_type']));   

$contentmsg=stripslashes("<br><b><font style=color:#CC3300>$subject</font></b><br>
<table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>

<tr>
  <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Full Name: </b> </td>
  <td width=565 align=left valign=top bgcolor=#FFFFFF> $full_name</td>
</tr>

<tr>
  <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Email Address: </b> </td>
  <td width=565 align=left valign=top bgcolor=#FFFFFF> $email</td>
</tr>

<tr>
  <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Type of Agent:</b> </td>
  <td width=565 align=left valign=top bgcolor=#FFFFFF> $agent_type</td>
</tr>

</table>
");

$headers  = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= 'To: Mary <mary@example.com>, Eric <eric@example.com>' . "\r\n";
$headers .= 'From: Website' . "\r\n";

if(mail($toemail,$subject,$contentmsg,$headers)){
header("Location: http://www.magnixsolutions.com/clients/tas/thanks.html"); 
}else{ 
  echo "Mail was not sent!"; 
} 
}
?>
  • 1
    You said it was working, what happens now? Just no email? Are you redirected or receive the error clause? Any problems in the error log file? Are you defo receiving other emails to that email address? – James Feb 15 '14 at 00:00
  • Im not expert in coding PHP, but I edited and made it work in the first place until something I did on the code that stopped sending the form to cluneborg@hotmail.com. I undo the changes and still didnt do the trick. I spent 2 hours figuring out what I did that messed up the code. – Christian Luneborg Feb 15 '14 at 00:09
  • 4
    It's no issue not being a PHP expert, that's why people ask here. It is an issue just stating "it doesn't work" however. Not being rude, it's just impossible to know what could be wrong (unless a code issue obvious in your above code, but I feel you should do some of the work to tell us what's wrong, rather than us spend ages checking your code, it's just polite as *you* need *our* help.) If you take your car to a mechanic and say "doesn't work" what would you expect them to do? – James Feb 15 '14 at 00:12
  • Try replacing all `"\n"`, with `"\r\n"` in you mail headers. – StackSlave Feb 15 '14 at 00:19
  • Yeah, it was me. I figured this out and it worked. Silly me. – Christian Luneborg Feb 15 '14 at 00:21
  • Did you [`see my answer`](http://stackoverflow.com/a/21793608/) in the other same question you asked about? There were a few issues with the code, details are shown in it. @ChristianLuneborg – Funk Forty Niner Feb 15 '14 at 15:29

0 Answers0