PHP Classes

Multiple Message Body in one email

Recommend this page to a friend!

      MIME E-mail message sending  >  MIME E-mail message sending package blog  >  How Can PHP Send Emai...  >  All threads  >  Multiple Message Body in one email  >  (Un) Subscribe thread alerts  
Subject:Multiple Message Body in one email
Summary:Multiple Message Body in one email
Messages:2
Author:Mark Smith
Date:2007-08-01 10:40:44
Update:2007-08-01 10:46:58
 

  1. Multiple Message Body in one email   Reply   Report abuse  
Picture of Mark Smith Mark Smith - 2007-08-01 10:40:44
Hello All,

I am sending one email to several people on a daily basis. The code I use to do this is:
$array = array('mail@mail.com', 'mail2@mail2.com');

foreach($array as $mailname) {
$site->SendQuoteReminder($mailname);
}

The SendQuoteReminder function code is below:

function SendQuoteReminder($to) {
//Set the From Address
$this->message->SetEncodedEmailHeader('From', EMAIL_FROM_ADDR, EMAIL_FROM_NAME);
//Set the To Address
$this->message->SetEncodedEmailHeader('To', $to, $to);
//Set the Bcc Address
$this->message->SetEncodedEmailHeader('Bcc', 'mail@mail.com', 'Mark Smith');
//Set the Subject
$this->message->setHeader('Subject', "We Want You Back!");
//Load the Imagw as an inline attachement
$image=array(
"FileName" => "http://www.site.com/images/email-header.jpg",
"Content-Type" => "automatic/name",
"Disposition" => "inline"
);
//Set the Image as var $image_part
$this->message->CreateFilePart($image,$image_part);
//Get ID of Image so it can be used inside message body
$image_content_id=$this->message->GetPartContentID($image_part);

//Define HTML version
$HTMLheader = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" .
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" .
"<head>\n" .
"</head>\n" .
"<body>\n" .
"<div class=\"all_content\">" .
"<img src=\"cid:". $image_content_id ."\" alt\"header\" width=\"558\" height=\"162\" />" .
"<div class=\"body_content\">\n";

$HTMLmessage = "<p>This is a test message.</p>\n";
$HTMLfooter = "</div>\n</div>\n" .
"</body>\n" .
"</html>";

//Define Text Version
$TXTmessage = strip_tags($HTMLmessage);

//Set HTML message as var $html_part
$this->message->CreateHTMLPart($HTMLheader . $HTMLmessage . $HTMLfooter, '', $html_part);

//Merge HTML message and Image
$related_parts=array(
$html_part,
$image_part
);
//Set HTML message and Image as $html_parts
$this->message->CreateRelatedMultipart($related_parts,$html_parts);

//Set Plain Text message as var $text_part
$this->message->CreatePlainTextPart($TXTmessage, '', $text_part);

//Merge the Text and HTML
$alternative_parts=array(
$text_part,
$html_parts
);
//Set as Multipart message
$this->message->AddAlternativeMultipart($alternative_parts);

//Send
$this->message->Send();
}

The problem I'm getting is that on the second email the text is appended to the first email content. I.e. in the second email the text would appear twice.

How would I delete all the variables after a message has been sent?

Many Thanks for your help.

  2. Re: Multiple Message Body in one email   Reply   Report abuse  
Picture of Mark Smith Mark Smith - 2007-08-01 10:46:58 - In reply to message 1 from Mark Smith
Just found the answer!!

I added the function ResetMessage() to the top of the function and all works well now.