MySQL Forums
Forum List  »  PHP

PHP mail() error
Posted by: Daniel White
Date: August 29, 2012 05:18AM

Hi everyone. I have gone over and over this and cannot see the fault.
The script emails the BCC perfectly, however it is not sending it to the "to" and "CC" recipients. The emails are not going to junk/spam folders and on the BCC, the to and CC addresses are appearing correctly on Outlook/Thunderbird.

Any ideas will be greatly appreciated. The script mails from two separate forms, and sends/prints a designated reply dependant on which form has been submitted, a call back form and general mail form.

---

if(isset($_GET["fs"]) && $_GET["fs"] == "cb"){
if(isset($_POST["sub"]) && isset($_GET["cb"])){
$emto = "enquiries@****.co.uk";
$headers = "From: callback-request@****.co.uk\r\n";
$headers .= "CC:****@****.co.uk\r\n";
$headers .= "BCC:****@****.com\r\n";
$headers .= "X-Mailer: PHP/".phpversion();
$subj = "Callback Requested - ****.co.uk";
$mesg = "Hi.\r\nA callback request has been submitted at ****.co.uk\r\n";
$mesg .= "Name: ".$_POST["name"]."\r\n";
$mesg .= "Telephone: ".$_POST["tel"]."\r\n";
$mesg .= "Company: ".$_POST["comp"]."\r\n";
$mesg .= "Time: ".$_POST["time"]."\r\n";
mail($emto,$subj,$mesg,$headers);
$return = "<div class=\"blk1\">
<h1 id=\"title\">Request Call Back</h1>
Thank you. We shall contact you between ".$_POST["time"].".
</div>";
}
else{
$return = "<div class=\"blk1\">
<h1 id=\"title\">Request Call Back</h1>
<a href=\"?fs=em\"><small>Click to send a message</small></a>
<form action=\"?fs=cb&cb\" method=\"post\">
<label for=\"name\">Your Name</label><br />
<input name=\"name\" class=\"inp-t\" /><br /><br />
<label for=\"comp\">Company</label><br />
<input name=\"comp\" class=\"inp-t\" /><br /><br />
<label for=\"tel\">Telephone Number</label><br />
<input name=\"tel\" class=\"inp-t\" /><br /><br />
<label for=\"time\">What is the best time for you? <small><em>Mon-Fri</em></small></label><br />
<select name=\"time\">
<option value=\"9.00-10.00\">9:00 - 10:00</option>
<option value=\"10.00-11.00\">10:00 - 11:00</option>
<option value=\"11.00-12.00\">11:00 - 12:00</option>
<option value=\"12.00-13.00\">12:00 - 13:00</option>
<option value=\"13.00-14.00\">13:00 - 14:00</option>
<option value=\"14.00-15.00\">14:00 - 15:00</option>
<option value=\"15.00-16.00\">15:00 - 16:00</option>
<option value=\"16.00-17.00\">16:00 - 17:00</option>
</select><br /><br />
<input type=\"submit\" class=\"subm\" value=\"Send Request\" name=\"sub\" />
</form>
</div>";
}
}
elseif(isset($_GET["em"]) && $_GET["fs"] == "em"){
if(isset($_POST["sub"])&& isset($_GET["em"])){
$emto = "enquiries@****.co.uk";
$headers = "From: contact-request@****.co.uk\r\n";
$headers .= "CC:****@****.co.uk\r\n";
$headers .= "BCC:****@****.com\r\n";
$headers .= "X-Mailer: PHP/".phpversion();
$subj = "Web Contact Form - ****.co.uk";
$mesg = "Hi.\r\nThe contact form has been submitted at ****.co.uk\r\n";
$mesg .= "Name: ".$_POST["name"]."\r\n";
$mesg .= "Telephone: ".$_POST["tel"]."\r\n";
$mesg .= "Company: ".$_POST["comp"]."\r\n";
$mesg .= "Message: ".$_POST["msg"]."\r\n";
mail($emto,$subj,$mesg,$headers);
$return = "<div class=\"blk1\">
<h1 id=\"title\">Email Us</h1>
Thank you. We shall respond as soon as we can.
</div>";
}
else{
$return = "<div class=\"blk1\">
<h1 id=\"title\">Email Us</h1>
<a href=\"?fs=cb\"><small>Click to request call back</small></a>
<form action=\"?fs=em&em\" method=\"post\">
<label for=\"name\">Your Name</label><br />
<input name=\"name\" class=\"inp-t\" /><br /><br />
<label for=\"comp\">Company</label><br />
<input name=\"comp\" class=\"inp-t\" /><br /><br />
<label for=\"tel\">Telephone Number</label><br />
<input name=\"tel\" class=\"inp-t\" /><br /><br />
<label for=\"ema\">Email Address</label><br />
<input name=\"ema\" class=\"inp-t\" /><br /><br />
<label for=\"msg\">Message</label><br />
<textarea name=\"msg\" id=\"inp-textarea\"></textarea>
<br /><br />
<input type=\"submit\" class=\"subm\" value=\"Send Message\" name=\"sub\" />
</form>
</div>";
}
}
else{};

-------
Dan White

UK based PHP developer & web designer.

http://prodesignagency.com



Edited 1 time(s). Last edit at 08/29/2012 06:17AM by Daniel White.

Options: ReplyQuote


Subject
Written By
Posted
PHP mail() error
August 29, 2012 05:18AM
August 29, 2012 06:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.