daniyalnawaz Posted October 8, 2007 Share Posted October 8, 2007 Hi! Im trying to send a html mail through PEAR but what I get in mail is blank email. Below is my code require_once "Mail.php"; require_once "Mail\mime.php"; $html = @file_get_contents(GetEmailBody()); $message = new Mail_mime(); $message->setHTMLBody($html); $body = $message->get(); $from = "abc@sample.com"; $namefrom = "Sample"; $to ="johnsmith@sample.com"; $nameto = "John Smith"; $subject = "Sample"; $host = "mail.sample.com"; $username = "sample@sample.com"; $password = "sample"; $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>"); } Thank you Daniel Nawaz Quote Link to comment https://forums.phpfreaks.com/topic/72283-send-html-mail-with-pear/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.