php mail not sending

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashrafzia
Forum Commoner
Posts: 37
Joined: Wed Sep 28, 2005 12:23 pm

php mail not sending

Post by ashrafzia »

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 :

Code: Select all

 
<?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>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</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();
?>
 
 
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
mikelbring
Forum Commoner
Posts: 38
Joined: Sat Jan 05, 2008 5:28 pm

Re: php mail not sending

Post by mikelbring »

Maybe no smtp on the server?
Post Reply