tags:

views:

145

answers:

2

I am trying to send an email from PHP using PHPmailer().
I have included the following syntax to display the content in a table.
I need to update the table to display the email when the email is received.
How can I accomplish this?

     $message ="<html><body> <table><tr><td>HELLO</td></tr></table></body></html>";
          $body = eregi_replace("[\]",'',$message);
          $mail             = new PHPMailer();
          $mail->From       = $email;
          $mail->FromName   = $Name;
          $mail->CharSet = "utf-8";
          $mail->Subject    = "GoodNoon:".$Name."";
          $mail->IsHTML(true);
          $mail->AltBody    = "To view the message, please use an HTML compatible email viewer";
          $mail->WordWrap = 50; 
          $mail->MsgHTML($body);
         // send as HTML
          $mail->AddAddress("[email protected]", "name");

         if(!$mail->Send()) {
            echo "Emai Not sent: " . $mail->ErrorInfo;
        } 
         else {
           echo "Email Sent";

          }
+1  A: 

First of all, you might want include a body tag. Replace:

<html><table><tr><td>HELLO</td></tr></table></html>

with

<html><body><table><tr><td>HELLO</td></tr></table></body></html>

Second:

  • How do the email contents look?
  • What e-mail client are you using?
  • Is HTML not being rendered at all, or just the <table> elements?

Sidenote: please try to provide more context when asking questions. You are more likely to receive positive and good responses to your questions if you take the time to review your question and make sure all the neccessary information is there and there are no (or at least, not many) formatting errors.

Aron Rotteveel
A: 

The problem is, I think, you miss the Content-type.

I use this :

$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn"; // or UTF-8
$headers .= "From: $from\r\n";

mail($to, $subject, $message, $headers);
RVeur23