PHP Email Problem

Discussion in 'PHP' started by vassili, Feb 21, 2008.

  1. #1
    i'm having problems getting an email generated by my php to display correctly. i basically have a script that generates some dynamic html, and then stores that as a string into a variable $order.

    i pass $order when the user submits the email, $order gets passed to the email php script. i checked the html string inside $order and it seems legit. it displays correctly in IE and FF yet, not in the email.

    i want it to look like this for the most part and this is how it displays in the browsers [top part]...but the email (gmail, hotmail, outlook] all displays it like the bottom bit. it gets really wide, has /" /" in between the input numbers and generally loses the "look". it's not using any css...


    http://itwonthurt.com/files/email.gif

    here's an example of html output from my script, copy paste to see what it should look like (include proper html headers and stuff):

    <table align="center" cellpadding="0" border="0"><tr><td><form action="browse.php?name=#6107AHAU" method="post" id="cart"><table align="center" cellpadding="0"  border="0"><tr><td></td>
                                            <td align="center">Style</td>
                                            <td align="center">Colour</td>
                                            <td align="center">Quantity of Sizes</td>
                                            <td align="center">Total Qty</td>
                                            <td align="center">Unit Price</td>
                                            <td align="center">Item Subtotal</td></tr><tr><td style="border:0px solid #999;"><a href="cart.php?action=delete&id=8908YBL" >Remove</a></td><td width="100" style="border:1px solid #999;" align="center">8908Y</td><td width="150" style="border:1px solid #999;" align="center">BLACK</td><td>
                                                    <table align="center" border="0"><tr>
                                                    <td valign="top" align="center">  6/8</td>
                                                    <td valign="top" align="center">10/12</td>
                                                    <td valign="top" align="center">14/16</td>
                                                    <td valign="top" align="center">   18</td>
                                                    <td valign="top" align="center">  3/4</td>
                                                    <td valign="top" align="center">  4/5</td>
                                                    <td valign="top" align="center">2/3</td>
                                                    <td valign="top" align="center">
    </td>
                                                    </tr>
                                                    <tr>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty18908YBL" value="1" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty28908YBL" value="1" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty38908YBL" value="0" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty48908YBL" value="0" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty58908YBL" value="0" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty68908YBL" value="0" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty78908YBL" value="0" size="1" maxlength="3"/></td>
                                                    <td valign="top" align="center"><input readonly="readonly" type="text" name="qty88908YBL" value="0" size="1" maxlength="3"/></td>
                                                    
                                                    </tr></table></td><td  style="border:1px solid #999;" align="center">2</td><td style="border:1px solid #999;" align="center">$8.75</td><td style="border:1px solid #999;" align="center">$17.50</td></tr></table><p align="right" style="font-size:16px;">Purchase Subtotal: <strong>$17.50</strong></p><div align="right"><button type="submit" id="mysubmit3">Continue Shopping</button></div></form></td></tr></table>
    Code (markup):

    my php email script is something like this.

    if(isset($_POST['submit'])) { 
    $to = "xxx@gmail.com, $dEmail, "; 
    
    $subject = "New Order From $name_field via $dealer";
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n";
    $headers .= "From: $name_field <order@xxx.com>\n";
      
    $body = "<br /><br /><p style='font-size:14px;'><span style='font-weight:bold;'>Order:</span> <br /><br />    $order</p>"; 
      
    $mailDelivery = "0"; 
    
    mail($to, $subject, $body, $headers); 
    } else { 
    
    $mailDelivery = "1"; 
    } 
    
    header("Location: blank.php?result=$mailDelivery");
    
    Code (markup):

     
    vassili, Feb 21, 2008 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    Where is $order getting set?
     
    zacharooni, Feb 21, 2008 IP
  3. vassili

    vassili Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oh sorry, all the variables get set before the if statement.
     
    vassili, Feb 21, 2008 IP
  4. zarcoss

    zarcoss Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hi,

    you also can use phpmailer(phpmailer.codeworxtech.com/) instead basic php mail function above.

    :D
     
    zarcoss, Feb 22, 2008 IP
  5. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would fix those headers to. php.net/mail

    Make sure they validate in all mail clients.
     
    LittleJonSupportSite, Feb 22, 2008 IP
  6. vassili

    vassili Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i've narrowed it down to this.

    when i store the html into the variable backslashes are inserted.

    $order = str_replace ("\'","'",$order);
    Code (markup):
    worked. thanks guys
     
    vassili, Feb 22, 2008 IP