Click here to Skip to main content
15,499,289 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a mail function which is working correctly, but i'm trying to send a html body along with that email. all i see just my html code inside the email. where i went wrong ?

What I have tried:


// Pear Mail Library
require_once "Mail.php";

$from = '';
$to = '';
$subject = 'Your Password Is Reseted - Automated Tollgate System!';
$body ='
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <h1>hi dear friend</h1>



$headers = array(
    'From' => $from,
    'To' => $to,
    'Subject' => $subject

$smtp = Mail::factory('smtp', array(
        'host' => 'ssl://',
        'port' => '465',
        'auth' => true,
        'username' => '',
        'password' => 'auto@2017',

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

if (PEAR::isError($mail)) {
    echo('<p>' . $mail->getMessage() . '</p>');
} else {
    $message = "Password reset link has sent to your email address";
    echo "<script type='text/javascript'>alert('$message');</script>";
    header("Location : index.php");
Updated 31-Jul-17 6:27am

1 solution

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900