Page 1 of 1

Pear Mail_Mime HTML Email Help

Posted: Wed Oct 12, 2011 9:56 am
by HSKrustofsky
I am attempting to email a newsletter page I created. I am fairly new to sending mail in PHP. Usually whatever is sent is plain text, so this is my first HTML email. I've created the main page where the content is(images, text content, etc...). I've also written the mailer script, and have gotten it to send an HTML email, but nothing really shows up. The only thngs that show up are certain CSS and HTML stylings I placed, and a broken image box. Now what I should be there is a list of news articles(3 or 4) with their images, which are broght in from my database.

Here is the code for the mailer:

Code: Select all

include 'connect.php'
include 'Mail.php'; 
include 'Mail/mime.php'; 

$message = new Mail_mime("\r\n"); 
$message->setHTMLBody(file_get_contents( 'mail-content.php' ));

//photo field containts image path
$sql = mysql_query("SELECT photo FROM article_info");
while($result = mysql_fetch_array($sql)) {
    $message->addHTMLImage("$result");
}

$body    = $message->get(); 
 
$to    = "to@email.com"; 
$from    = "form@email.com"; 
$subject = "Mail_Mime HTML Test"; 
$hdrs    = array('From'    => $from, 
                    'To' => $to, 
                    'Return-Path' => $from, 
                    'Subject' => $subject); 

$headers = $message->headers($hdrs); 

$smtp = mail-server.email.com;
$sender  =& Mail::factory('smtp', $smtp); 
$sender->send($to, $headers, $body); 
That's what I've got. I've been searching and can't seem to find anything. Any suggestions? Thanks in advance.