Adido / formz

Form Builder extra for MODX Revolution
8 stars 9 forks source link

Multiple email addresses #4

Open isaacniebeling opened 10 years ago

isaacniebeling commented 10 years ago

The UI for forms that are emailed includes "Recipients"; however, in my testing, only single email addresses work. Documentation on modMail suggests that each address needs to be added separately:

$modx->mail->address('to','user@example.com');
$modx->mail->address('to','mom@example.org');

Should be fairly straightforward to update ~line 117 of formzhooks.class.php. I can submit a pull request at some point in the near future to fix it, unless you get to it first.

isaacniebeling commented 10 years ago

Just tested and this should work:

change lines 109-116 to:

            $emailToAddresses = explode(',', $this->config->emailTo);
            $message = $this->fmz->getChunk($this->config->emailTpl, $newData);

            $this->modx->getService('mail', 'mail.modPHPMailer');
            $this->modx->mail->set(modMail::MAIL_BODY, $message);
            $this->modx->mail->set(modMail::MAIL_FROM, $this->config->emailFrom);
            $this->modx->mail->set(modMail::MAIL_FROM_NAME, $this->config->senderName);
            $this->modx->mail->set(modMail::MAIL_SUBJECT, $this->config->subject);
            foreach($emailToAddresses as $address) {
              $this->modx->mail->address('to', trim($address));
            }

I'll still try to figure out pull requests at some point :p