Cannot Seem To Replace More Than 1 Personalization Token

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
jbh
Forum Commoner
Posts: 89
Joined: Tue Dec 05, 2006 7:01 pm

Cannot Seem To Replace More Than 1 Personalization Token

Post by jbh »

Edit: Found the fix for those who want to do this.

When creating the loop, use this: (Thanks to the author for suggesting this in an archived post

$search = array("[first]", "[last]", "[username]"); // These are the tokens use you. Format them accordingly
$replace = array($first, $last, $username); // those are the variables you use to replace the tokens, obviously

Then, you do this:

$message->setBody(str_replace($search, $replace, $emailmessage)); // replace $emailmessage with the proper variable for your "message" variable

I hope this helps somebody.
Post Reply