SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    email not working

    please email code not working,

    PHP Code:
        //Get list to email user
         
    $body " Hello $cust_id</br>";
          
    $body .= "</br>";
    $body .= "We are happy to inform you that your order has been received</br>Thanks for making the part payment of &#8358 "number_format($tranx_amt2'.''') ." ,<br />Your Payment reference no is $orderno.<br /><br />";
         
       
    $body .= "<html><body><table border='1'>
    <tr>
    <th></th>
    <th>Shop Name</th>
    <th>Product Name</th>
    <th>Size</th>
    <th>Color Name</th>
    <th>Quantity</th>
    <th>weblink</th>
    <th>Price</th>
    <th>Cost</th>
    </tr>"
    ;
    $totalPrices 0;
    $rowNum 1;
    $pplresult mysql_query("SELECT * FROM repplac WHERE Uname = '{$_SESSION['username']}'ORDER BY Sname ASC");   
    while(
    $row mysql_fetch_assoc($pplresult)){ 
        
    $body .= "<tr>
            <td>"
    .$rowNum++."</td>
            <td>" 
    $row['Sname'] ."</td>
            <td>" 
    $row['Pname'] ."</td>
            <td>" 
    $row['Psize'] ."</td>
            <td>" 
    $row['Pcolour'] ."</td>
            <td>" 
    $row['Pquantity'] ."</td>
            <td>" 
    $row['Weblink'] ."</td>
            <td>" 
    $row['Price'] ."</td>
            <td>" 
    $row['Tprice'] ."</td>
            </tr>"
    ;
             
    $totalPrices += $row['Tprice'];
    }

         if(
    0.1*$totalPrices <= 50 )
        {
        
    $totalprice = (0.1*$totalPrices +  $totalPrices);
        }
        else
       {
        
    $totalprice 50 $totalPrices;
            }
    $body .= "<tr>
                <td colspan=6>Total :</td> 
                           
                <td>" 
    $totalprice ."</td>
            </tr>"
    ;

    $body .="</table></body></html><br /><br />";
    //$body .="</ br>";
    $body .="$fullname</br>$houseno</br> $addressa</br>$addressb</br>$addressc</br>$county</br>$state</br>$country</br></br>";
    $body .="Please do not hesitate to contact us for any information via support@reacheasy.co.uk</ br>Thanks!";
       
    //Send email
    $to $email
       
    $subject "YOUR ORDER LIST($orderno) FROM REACHEASY"
     
    $headers "From: donotreply@reacheasy.co.uk\r\n"
                
    'MIME-Version: 1.0' "\r\n"
                
    'Content-type: text/html; charset=iso-8859-1' "\r\n";
                
    //. 'Bcc:mgltd@me.com' . "\r\n";

    mail($to,$subject,$body,$headers); 

  2. #2
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    its now working, i did not really do anything different to it

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Hard to say going only by "not working" without error messages, but it could be the code is fine and that the problem was with the email server.
    PHP mail() only sends it off and can't let you know if the problem was afterwards.

  4. #4
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    earlier, it wasn't working, but all the code after it was working. then just opening the file and trying to echo/die just to trouble shoot the code, it worked

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Swap out the last line with the below and post the result.

    PHP Code:
    echo '<p>Mailed: '.( mail($to,$subject,$body,$headers)?'YES':'NO' ).'</p>'
    Heads up if you don't see YES or NO than there is a syntax and/or logic error somewhere higher up in the code. If you see YES or NO than the mailer isn't functioning properly which isn't a PHP issue, it is more a devops/server issue.

    Though I did just notice that $email is never defined in that script. So that is likely the cause unless you have other scripts being included which are not present in your post or register globals on which you shouldn't.

    here is an easy way to check that hunch:

    PHP Code:
    echo "<p>email: '$email'</p>";
    mail($to,$subject,$body,$headers); 
    if email is empty than well the problem is that email is not defined.
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •