我想使用decorator
向用户发送自定义消息。
由于某种原因,发送了相同的消息。
为什么?
$replacements = array();
$replacements['f1@d.net'] = array(
'{v1}' => 'valoare1',
'{v2}' => 'valoare2',
);
$replacements['f2@d.net'] = array(
'{v1}' => 'valoare21',
'{v2}' => 'valoare22',
);
$replacements['f3@d.net'] = array(
'{v1}' => 'valoare31',
'{v2}' => 'valoare32',
);
$replacements['f4@d.net'] = array(
'{v1}' => 'valoare41',
'{v2}' => 'valoare42',
);
$replacements['f5@d.net'] = array(
'{v1}' => 'valoare51',
'{v2}' => 'valoare52',
);
echo count($replacements);
$decorator = new \Swift_Plugins_DecoratorPlugin($replacements);
$mailer = \Swift_Mailer::newInstance(
\Swift_SmtpTransport::newInstance('smtp', 25)
);
$mailer->registerPlugin($decorator);
$message = \Swift_Message::newInstance()->setSubject('title {v1}')->setBody('layout {v2}');
foreach ($replacements as $email => $replacement) {
$message->setFrom(array($email => 'to me'));
// $message->setTo($email);
$message->addTo($email);
$mailer->send($message);
}