Hi I am using the PHP mail function for sending e-mails but its not sending the mail and i m also not getting any error. Heres my code : <?php ob_start(); session_start(); include("menu.php"); include("functions.php"); show_header(); error_reporting(E_ALL); //print "client id is : $_SESSION[client_id]"; $to = "ashrafzia@yahoo.com"; $subject = "Invoice Reminder"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //'MIME-Version: 1.0'."\r\n".'Content-type: text/html; charset=iso-8859-1'."\r\n" // Additional headers $headers .= 'To: Ashraf <ashrafzia@yahoo.com>' . "\r\n"; $headers .= 'From: Invoice Reminder <invoice@example.com>' . "\r\n"; $headers .= 'Cc: invoice@example.com' . "\r\n"; $headers .= 'Bcc: invoice@example.com' . "\r\n"; $sql = "SELECT * from client_info, payments, services_ordered where client_info.client_id=$_SESSION[client_id] "; //print "<br><br><br>".$sql; $res = mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_assoc($res)){ $c_name = $row['f_name']." ".$row['l_name']; $c_add = $row['address']; $country = $row['country']; $state = $row['state']; $pcode = $row['p_code']; $mob = $row['mob_ph']; $ph = $row['hom_ph']; $bank = $row['bank_name']; $acc_name = $row['acc_name']; $acc_no = $row['acc_no']; $bsb = $row['bsb_no']; // $s_date = $row['due_date']; $a_name = $row['admin_name']; $a_add = $row['admin_add']; $c_no = $row['contact_no']; } $mailbody = " <table align='center'> <tr> <td><table> <tr> <td colspan='2'><div align='center'><strong>Admin Details</strong></div></td> </tr> <tr> <td>Name : </td> <td>$a_name</td> </tr> <tr> <td>Account No :</td> <td>$acc_no</td> <tr> <td>Address :</td> <td>$a_add</td> </tr> <tr> <td>Contact No : </td> <td>$c_no</td> </tr> <tr> <td>Bank Details : </td> <td>$bank</td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table></td> <td><table> <tr> <td colspan='2'><div align='center'><strong>Client Info </strong></div></td> </tr> <tr> <td>Name:</td> <td>$c_name</td> </tr> <tr> <td>Address:</td> <td>$c_add</td> </tr> <tr> <td>Country:</td> <td>$country</td> </tr> <tr> <td>State:</td> <td>$state</td> </tr> <tr> <td>Post Code: </td> <td>$pcode</td> </tr> <tr> <td>Mobile No: </td> <td>$mob</td> </tr> <tr> <td>Phone No: </td> <td>$ph</td> </tr> </table></td> </tr> <tr> <td colspan='5'><table width='100%' align='center'> <tr> <td colspan='4'><div align='center'> <strong>Services Availed</strong> </div></td> </tr> <tr class='trbg'> <td><div align='left'><strong>Service Name</strong></div></td> <td><div align='center'><strong>Date</strong></div></td> <td><div align='center'><strong>Admin Comments</strong></div></td> <td><div align='center'><strong>Adjusted Price </strong></div></td> </tr> <tr>"; // $clientid = mysql_real_escape_string($_POST['c_id']); $sql = "SELECT service_ordered, admin_comments, ordered_date, adj_price from services_ordered where services_ordered.client_id=$_SESSION[client_id]"; $res = mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_array($res)){ $s_names = $row['service_ordered']; $d_date = $row['ordered_date']; $a_comments = $row['admin_comments']; $adj_price = $row['adj_price']; $mailbody .="<td>$s_names</td> <td>$d_date</td> <td>$a_comments</td> <td align='center'>$adj_price</td> </tr>"; } // $clientid = mysql_real_escape_string($_POST['c_id']); $sql = "SELECT SUM(adj_price) as tot_price from services_ordered where services_ordered.client_id=$_SESSION[client_id]"; $res = mysql_query($sql) or die(mysql_error()); $row=mysql_fetch_array($res); $my_price = 0; $my_price = $my_price + $row['tot_price']; /* if (isset($my_price)){ echo "My Price is set: $my_price"; } */ $mailbody .=" <tr> <td colspan='3' class='trbg'><strong>Total Price: </strong></td> <td align='center' class='trbg'><strong>$my_price</strong></td> </tr> </table></td> </tr> </table> </form>"; echo "<br>"; //echo "$mailbody"; // Mail it $send = mail($to, $subject, $mailbody, $headers); if ($send) { echo "<strong><center><h2>Mail sent</h2></center></strong>"; } else { echo "Error in Sending Mail"; } show_footer(); ?> PHP: I don't know what's the problem, I have even tried using a simple mail using the mail() but no fruitful result. please help Thanks in advance
If everything seems to be OK, then try to ask your hosting provider. Sometimes the problem lies in the server. Have you try to send a simple email (use the sample script from the manual)?
maybe your hosting provider do not sopport emailing, try sending your emails throw other emails providers.
I agree with everyone else here. A lot of shared hosts either have limits on the number of calls that can be made with mail() per hour or don't allow it at all. It's a classic mechanism for spammers so not a lot of hosts allow free use of it.
er.. did you try : mail($to, $subject, $mailbody, $headers); instead of : $send = mail($to, $subject, $mailbody, $headers); ??