PHP Classes

Sending mails to many addresses

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  >  Sending mails to many addresses  >  (Un) Subscribe thread alerts  
Subject:Sending mails to many addresses
Summary:Every mail body appends to previously sent.
Messages:2
Author:Petar
Date:2007-10-16 17:50:56
Update:2007-10-16 19:25:56
 

  1. Sending mails to many addresses   Reply   Report abuse  
Picture of Petar Petar - 2007-10-16 17:50:56
Hi,

I have a problem sending mails with email_message_class - every message appends to previously sent.

Code:

$message_object=new email_message_class;
$result=mysql_query("SELECT * FROM outbox");

while ($row = mysql_fetch_assoc($result)) {
$message_object->ResetMessage;
$message_object->SetEncodedEmailHeader("Reply-To", $row['EmailFrom'], $row['EmailFromName']);
$message_object->SetHeader("Errors-To",$error_delivery_address);
if(defined("PHP_OS") && strcmp(substr(PHP_OS,0,3),"WIN"))
$message_object->SetHeader("Return-Path",$error_delivery_address);
$message_object->SetEncodedEmailHeader("From", $row['EmailFrom'], $row['EmailFromName']);
$message_object->SetEncodedEmailHeader("To", $row['EmailTo'], $row['EmailToP']);
$message_object->SetHeader("Subject",$row['Subject']);
$message_object->AddQuotedPrintableTextPart($message_object->WrapText($row['Message']));
$eml_error = $message_object->Send();
}

I want to send simple text-plain messages. I do not want to use Bulk Mail.

Please tell me where the problem is...

Thanks

  2. Re: Sending mails to many addresses   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-10-16 19:25:56 - In reply to message 1 from Petar
You have a mistake in the ResetMessage call. It should be:

$message_object->ResetMessage();

Anyway, if you want to send different messages to each user but with the same format, it is better to use ReplacePart calls like in the test_personalized_bulk_mail.php example script.