Jump to content

Send HTML mail with PEAR


daniyalnawaz

Recommended Posts

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 = "[email protected]";
      $namefrom = "Sample";
      $to ="[email protected]";
      $nameto = "John Smith";
      $subject = "Sample";

      $host = "mail.sample.com";
      $username = "[email protected]";
      $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

Link to comment
https://forums.phpfreaks.com/topic/72283-send-html-mail-with-pear/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.