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);
}