public function sendUsingModel($identifier, $toEmail, $toName = '', $data = []) { $email = new EmailModel(); if ($email->loadByField('identifier', $identifier)) { $template = $email->getTemplate(); $fromName = $email->getFromName(); $fromEmail = $email->getFromEmail(); $subject = $this->replaceData($template->getSubject(), $data); $markup = $this->rel2abs($this->replaceData($template->getMarkup(), $data)); $body = PHP_EOL . $this->rel2abs($this->replaceData($template->getContent($markup), $data)); // reset recipients $this->clearAllRecipients(); // to $this->addAddress($toEmail, $toName); // from $this->From = $fromEmail; // fromName $this->FromName = $fromName; // subject $this->Subject = $subject; // utf8 please $this->CharSet = 'utf-8'; // body $this->msgHTML($body); // send! $status = $this->send(); // log if (class_exists('MailerlogModel')) { MailerlogModel::log($fromEmail, $fromName, $toEmail, $toName, $subject, $body, $status ? 1 : 0); } return $status; } else { throw new Ajde_Exception('Email with identifier ' . $identifier . ' not found'); } }