Click here to Skip to main content
15,503,579 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:

<?php

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

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


        <h1>hi dear friend</h1>

    </body>
</html>

';
       
        

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

$smtp = Mail::factory('smtp', array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => '465',
        'auth' => true,
        'username' => 'automated@gmail.com',
        '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");
}
Posted
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