problem with sending table in php mail

Discussion in 'PHP' started by adsegzy, Oct 14, 2010.

  1. #1
    I am having problem with sending a table in php mail.
    i have searched for help in google.com and forums, but the reply am getting is as below;

    $message="<table>
    /*my content will go here*/
    </table>";
    
    PHP:
    or

    $message = '
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <table>/*my content will go here*/</table>
    </body>
    </html>';
    PHP:

    which i tried but it will always show the table codes in the mail, not making the mail look readable.

    what else can i do?

    regards
     
    adsegzy, Oct 14, 2010 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    can you share a sample email content?

    that will give us idea of what is causing problem.
     
    mastermunj, Oct 14, 2010 IP
  3. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #3
    If you are sending an HTML email, and you are only getting the HTML code as part of the email, you are not sending it as the correct content type. This isnt a problem with your formatting/body - you need to set the headers on the email so the email client is aware of this.

    Something like this should work, when you send it;

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    PHP:
    You can include other headers by concatenating them onto the end (to, from, cc etc) and make sure
    you actually send the headers as part of the mail call;

    mail($to, $subject, $message, $headers);
    PHP:
    You might also want to look at using PEAR::Mail_Mime instead as recommended from the PHP reference.
     
    lukeg32, Oct 14, 2010 IP