I have the following functions that sends batch emails
public function sendAttendeeEmails(Swift_Plugins_DecoratorPlugin $decorator, int $per_emails = 5, int $pause = 5) : int
{
$this->mailer->registerPlugin($decorator)
// ->registerPlugin(new \Swift_Plugins_AntiFloodPlugin($pre_emails, $pause))
// ->registerPlugin(new \Swift_Plugins_ThrottlerPlugin(
// $per_emails, \Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
// ))
;
array_walk($this->getAttendees(), [ $this, 'sendEmail' ]);
return empty($this->failed)? $this->sent : -1;
}
In my "sendEmail" function
protected function sendEmail($recipient, $email) {
$message = new Swift_Message();
$
$message->attach(
Swift_Attachment::fromPath(
ASSETS_FOLDER . "/{$recipient['code']}.pdf",
'application/pdf'
)->setFilename("{$recipient['code']}-attachment.pdf")
);
$this->message->setTo([ $email => $recipient['name']]);
$this->sent = $this->mailer->send($this->message, $this->failed);
}
Based on the documentation
Create a Transport from one of the provided Transports -- Swift_SmtpTransport, Swift_SendmailTransport, or one of the aggregate Transports. Create an instance of the Swift_Mailer class, using the Transport as it's constructor parameter. Create a Message. Iterate over the recipients and send message via the send() method on the Mailer object.
However, in executing the functions it appears that attachments and email addresses are being appended onto subsequent emails
My understanding that messages and email addresses would be sent uniquely
I need to send each individual a specific attachment without being aware of one another