protected function mail($ticket) { require FRAMEWORK . DS . 'conf' . DS . 'myticket.php'; $replyto = ''; $usermodel = new userModel(); $user = $usermodel->getfromDisplayname($ticket->getContact()); if (count($user) == 1) { $mail = $user[0]->getMail(); if ($mail != '') { $replyto = $mail; } else { $replyto = $defaultfrom; } } else { $replyto = $defaultfrom; } $dienstModel = new groupModel(); $dienstname = ''; $dienst = $dienstModel->getfromId($ticket->getDienstid()); if (count($dienst) == 1) { $dienstname = $dienst[0]->getDescription(); } $to = ''; $meldingdienstenModel = new meldingdienstenModel(); $dienstto = $meldingdienstenModel->getfromId($ticket->getTo()); if (count($dienstto) == 1) { $to = $dienstto[0]->getMail(); $toname = $dienstto[0]->getName(); } else { throw new Exception('No mail address for recipiënt'); } $subject = 'Melding [' . $ticket->getId() . '] aan [' . $toname . ']: ' . $ticket->getTitel(); $message = '<h1>Melding ' . $toname . '</h1>'; $message .= ' <table> <tr> <td valign="top"><strong>Naam:</strong></td> <td>' . $ticket->getContact() . '</td> </tr> <tr> <td valign="top"><strong>Afdeling:</strong></td> <td>' . $dienstname . '</td> </tr> <tr> <td valign="top"><strong>Omschrijving:</strong></td> <td>' . nl2br($ticket->getMessage()) . '</td> </tr> </table> '; return mail($to, $subject, $message, 'Content-Type: text/html; charset=UTF-8' . "\r\n" . 'From: ' . $replyto . "\r\n" . 'Reply-To: ' . $replyto, '-f ' . $replyto); }