* If you are using Windows, you need to use the smtp_message_class to set the return-path address. */ if (defined("PHP_OS") && strcmp(substr(PHP_OS, 0, 3), "WIN")) { $email_message->SetHeader("Return-Path", $error_delivery_address); } $email_message->SetEncodedEmailHeader("Errors-To", $error_delivery_address, $error_delivery_name); $email_message->SetEncodedHeader("Subject", $subject); /* If you are not going to personalize the message body for each recipient, * set the cache_body flag to 1 to reduce the time that the class will take * to regenerate the message to send to each recipient */ $email_message->cache_body = 0; $message = "Hello,\n\nThis message is just to let you know that Manuel Lemos' e-mail sending class is working as expected for sending personalized messages.\n\nThank you,\n{$from_name}"; /* Create empty parts for the parts that will be personalized for each recipient. */ $email_message->CreateQuotedPrintableTextPart($message, "", $text_part); /* Add the empty part wherever it belongs in the message. */ $email_message->AddPart($text_part); /* Iterate personalization for each recipient. */ for ($recipient = 0; $recipient < count($to); $recipient++) { /* Personalize the recipient address. */ $to_address = $to[$recipient]["address"]; $to_name = $to[$recipient]["name"]; $email_message->SetEncodedEmailHeader("To", $to_address, $to_name); /* Do we really need to personalize the message body? * If not, let the class reuse the message body defined for the first recipient above. */ if (!$email_message->cache_body) { /* Create a personalized body part. */ $message = "Hello " . strtok($to_name, " ") . ",\n\nThis message is just to let you know that Manuel Lemos' e-mail sending class is working as expected for sending personalized messages.\n\nThank you,\n{$from_name}"; $email_message->CreateQuotedPrintableTextPart($email_message->WrapText($message), "", $recipient_text_part); /* Make the personalized replace the initially empty part */ $email_message->ReplacePart($text_part, $recipient_text_part);