sending batch email with unique custom message

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

sending batch email with unique custom message

Post by kendall »

I am currently using SwiftMailer to send batch emails using the plugin decorator to customize a message template. The question is....can I use the same method to customize a different message template for each email I send.

Do I need to create a new instance of the message each time ?
$recipients->addTo($alerts->useremail,$alerts->contactname);
$replacements[$alerts->useremail] = array(
'{description}'=>$alerts->description,
'{name}'=>$alerts->contactname
'{alert}'=>$alerts->alertuserid
);

$swift->attachPlugin(new Swift_Plugin_Decorator($replacements), "decorator");
$message =& new Swift_Message("Triniscene Events Alerts");
$message->attach(new Swift_Message_Part(strip_tags(str_replace("<br/>","\r\n",$body_text))));
$message->attach(new Swift_Message_Part($body_text, "text/html"));
$swift->send($message, $recipients, "alerts@triniscene.com");
in a while loop statement Or do I just need to create new attachments...
$recipients->addTo($alerts->useremail,$alerts->contactname);
$replacements[$alerts->useremail] = array(
'{description}'=>$alerts->description,
'{name}'=>$alerts->contactname
'{alert}'=>$alerts->alertuserid
);

$swift->attachPlugin(new Swift_Plugin_Decorator($replacements), "decorator");

$message->attach(new Swift_Message_Part(strip_tags(str_replace("<br/>","\r\n",$body_text))));
$message->attach(new Swift_Message_Part($body_text, "text/html"));

in a while loop

I was reading the docs and the swift mailer is able to cache information to be re-used in situations like this. I'm fearing if I just looped the $message->attach i would just be appending the message information into one message rather than a message per user...would I be overloading if i kept making a $swift->attachPlugin() ?

What would be a recommended solution to try?
Post Reply