ok, so I have a basic form that takes the data and writes it to a mysql database. First part works fine. Information gets written to my database with no problems.
However, the email part of the code doesn't work so good. I always get the 'email failed to send error'.
I have no clue why this won't work. My server has the Default Virtual SMTP configured but other than that I'm not sure what else to check.
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$fn = $_POST['fn'];
$ln = $_POST['ln'];
$email = $_POST['email'];
$reason = $_POST['reason'];
$ip = $_POST['ip'];
$site = $_POST['site'];
$SQL = " INSERT INTO request ";
$SQL = $SQL . " (fn, ln, email, reason, ip, site, reply) VALUES ";
$SQL = $SQL . " ('$fn', '$ln','$email','$reason','$ip','$site', '') ";
$result = mysql_db_query($db,"$SQL",$cid);
if (!$result) {
echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
echo ("REQUEST SUBMITTED");
}
mysql_close($cid);
$to = 'email@email.org' ; \\ I edited this out, I had my correct email before.
$from = '' ;
$name = $_POST['ln'] ;
$subject = "Web Site Request - ";
$body = "A web site has been requested to be unblocked";
$send2 = mail ($from, 'Request Received' , 'Your request has been received. Request made before 5pm Monday - Friday are normally handled the same business day. All other requests will be handled on the next business day. Please be advised: all requests will receive another follow up email. If you have not received a response in two business days please call the office at 1-xxxxxxxx.
PLEASE DO NOT REPLY TO THIS EMAIL');
$send = mail($to, $subject, $body);
if($send)
{echo "REQUEST SENT -
Please check your email for more information.
- Thank You";}
else
{print "EMAIL FAILED"; }
?>