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 = "[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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.