Problem with Decorator plugin

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
Triss
Forum Newbie
Posts: 1
Joined: Tue May 19, 2009 10:09 am

Problem with Decorator plugin

Post by Triss »

Hello, I have a slight problem with the Swiftmailer Decorator plugin. I have read the documentation extensively, and so I have a replacement array in the form:

Code: Select all

$replacements = array("email" => array("{placeholder}" => "replacement"));
However when I started testing it, I found that each email I send to different addresses has the placeholders replaced by the replacements specified for the first email, and not its own. I have checked the email addresses and placeholder names multiple times and nothing is misspelled or assigned incorrectly.

I feel I might be missing something, although I think I've followed all instructions to the letter.

Aside from that, it's working perfectly, it's just that the replacements are wrong for all emails after the first!

EDIT: I realised I was using version 3, so I upgraded it and got the latest version of Swiftmailer. However after setting it all up and rewriting my code to fit version 4, I'm still getting this same problem.

EDIT2: So, being proactive, I've been delving into the Decorator Plugin code to try and better understand what is happening. I found this:

Code: Select all

$to = array_keys($message->getTo());
    $address = array_shift($to);
Now, is the Decorator Plugin called before each email is sent, and if so, does this mean that $to would be reset to the original $message->getTo() array instead of the array with the previous value removed by array_shift()? I'm not an expert in php, but I think I can see how this would cause a problem...or am I completely barking up the wrong tree here? However if indeed this is the problem, I'm not sure what I should do to make it work properly.
Post Reply