Hi, I need a little help... I'm trying to enable an auto-mail function. What I want is whenever an admin post a completed project, it should automatically email the customer. I'm having problems with this code: if($completed_file){ move_uploaded_file($completed_file['tmp_name'], $dir.'/'.$completed_file['name']); $completed_filename = $completed_file['name']; $sql .= ",file = '".$completed_filename."', status = '0'"; $sql ="SELECT * FROM `".CONFIG."`"; $rs = $db->query($sql); $config = $rs->fetch_assoc(); $header = "From: ".$config['email']."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $heading= "Project Completed"; $sql = "SELECT * FROM tbl_projects where id = '".$_POST["id"]."'"; $rs = mysql_query($sql); $row_project = mysql_fetch_array($rs); $sql = "SELECT * FROM tbl_users where `id`='".$row_project['uid']."'"; $rs = mysql_query($sql); $row_user = mysql_fetch_array($rs); $body="<table width=100% style='font-size: medium; padding: 1em; background-color:#FFFFFF; border-color:#8c9399; border-width:14px; border-style:solid;'> <tr><td><font face=Arial, Helvetica, sans-serif size=6px>Welcome to ".$configrow['website_title'].",</font><br/><br/></td></tr> <tr><td><font face=Arial, Helvetica, sans-serif size=4px>Pls Check your Revised Request Complated</font><br/><br/></td> </td></tr> <tr><td><font face=Arial, Helvetica, sans-serif size=4px>Regards, ".$configrow['website_title'].". </td></tr></table>"; @mail($row_user['email'],$heading,$body,$header); } PHP:
What is the problem actually? can paste it here? If you're not seeing any error, please remove @ in your code.
Always check return values... From this you can not say that your email was sent or not. if(mail($row_user['email'], $heading, $body, $header)) { echo 'Mail sent'; } else { echo 'Error, something went wrong while sending'; } If you got an error, you should check your php configuration, some hosts disable this.
Most of php mail ends up in spam therefore I recommend to use a SMTP service like SendGrid provides just google it, they give 200 emails per day for free!