I’m sending multiple messages at once in a loop. After each message I do ’$modx->mail->reset()’
For some reason this does not work for ’$mail->address(’reply-to’, ’
[email protected]’)’ The reply-to address is added to the reply-to address of the previous message.
Is this a bug or am I doing something wrong?
<?php
foreach($queue as $qitem)
{
$this->modx->mail->set(modMail::MAIL_BODY, $qitem->get('message'));
$this->modx->mail->set(modMail::MAIL_FROM, $qitem->get('from') );
$this->modx->mail->set(modMail::MAIL_FROM_NAME, $qitem->get('fromname') );
$this->modx->mail->set(modMail::MAIL_SENDER, $qitem->get('fromname'));
$this->modx->mail->set(modMail::MAIL_SUBJECT, $qitem->get('subject'));
$this->modx->mail->address('to', $qitem->get('to'));
$this->modx->mail->address('reply-to', $qitem->get('from'));
$this->modx->mail->setHTML(true);
if (!$this->modx->mail->send()) {
$this->modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
}
$this->modx->mail->reset();
}
?>