We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34075 ☆ A M B ☆
    • 130 Posts
    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();
                }
    ?>
    
      Jeroen Kenters

      MODX Professional | MODX Ambassador | Dutch MODX forums moderator

      website | twitter
      • 28215
      • 4,149 Posts
      Hi! Can you file that here: http://bugs.modx.com
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 25284
        • 141 Posts
        Couldn’t see a bug raised, so I’ve raised a new one
        http://bugs.modx.com/issues/3920

        Hope its not a duplicate, I’m having same issue though.