Jump to content

HTML mail issue


Deoctor

Recommended Posts

Hai

i have made one email program with the html content but still i get the html code in my mail

can any one help me out..

<!-- send mail using  an smtp-->

<?php
require_once "Mail.php";

$from = "";
$to = "";
$subject = "Hi!";
$body = "<h1>Hi</h1>,\n\nHow are you?";
$body .= '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';
$host = "";
$username = "";
$password = "";
/*$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";*/
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

Link to comment
Share on other sites

You can try using ob_start()

and in some mail boxes html is disabled by default.

So in some thing like SquirrelMail html might be disabled when in hotmail it will be enabled.

 

i am sending the mail to my gmail id using my smtp server..

when i send it using the localhost it does not sent in the html format

where as if i send using my server it sends..

but i want the mail to be sent using my local host

so hw do i do it..??

 

Link to comment
Share on other sites

i am not expert in sending mails over pear but where did you tell it that it is a  html/text type mail, you have to specify that in the body content.... don't know how to do it with pear tough i suggest not to use it, from the bottom of my heart :rtfm:

Link to comment
Share on other sites

hi sangoku

i dont know whether u have checked the code properly

but here is where i am mentioning to content type

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.