From 6e0596959b83ae6667b9ae23ce67ec816d120e7c Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Fri, 13 Mar 2026 01:51:35 +0200 Subject: [PATCH] =?UTF-8?q?Korjaa=20Zammad-vastauksen=20s=C3=A4hk=C3=B6pos?= =?UTF-8?q?til=C3=A4hetys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lisätty subtype: 'reply' Zammad-artikkelin luontiin — ilman tätä Zammad luo artikkelin mutta ei lähetä sähköpostia vastaanottajalle. Myös plain-text muunnetaan HTML:ksi ja subject saa Re: -etuliitteen. Co-Authored-By: Claude Opus 4.6 --- api.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api.php b/api.php index db1f04b..a34ca73 100644 --- a/api.php +++ b/api.php @@ -305,16 +305,22 @@ class ZammadClient { /** Lähetä vastaus tikettiin */ public function createArticle(int $ticketId, string $body, string $to = '', string $subject = '', string $type = 'email'): array { + // Muunna plain-text HTML:ksi jos body ei sisällä HTML-tageja + $htmlBody = $body; + if (strip_tags($body) === $body) { + $htmlBody = nl2br(htmlspecialchars($body, ENT_QUOTES, 'UTF-8')); + } $data = [ 'ticket_id' => $ticketId, - 'body' => $body, + 'body' => $htmlBody, 'content_type' => 'text/html', 'type' => $type, + 'subtype' => 'reply', 'internal' => false, 'sender' => 'Agent', ]; if ($to) $data['to'] = $to; - if ($subject) $data['subject'] = $subject; + if ($subject) $data['subject'] = 'Re: ' . preg_replace('/^Re:\s*/i', '', $subject); return $this->request('POST', 'ticket_articles', $data); }