diff --git a/CHANGELOG.md b/CHANGELOG.md index c2f7793eb..ba1f08101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,8 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u ### Bug Fixes +- Ticket emails: with Microsoft 365, cancelling a ticket's schedule left every "Ticket Schedule Cancelled" email failing with "SMTP Error: data not accepted", however often it was retried. The cancellation went in the email as a meeting cancellation with no organiser or attendees, which Microsoft 365 turns away. It's now attached as a calendar file, the same way the booking is, for the recipient to open and take the visit off their calendar. Event invitations and their cancellations, which have attendees, go as before. +- Mail queue: when the mail server turns an email away, Admin > Mail Queue and the failure notice now show what the server said, not only the step that failed - "SMTP Error: data not accepted. The mail server said: 554 5.2.0 ..." - which usually says why. - Invoices, quotes and contracts: opening one from its link while signed in to ITFlow - View as Client - counted as the client viewing it. A sent one became Viewed, its history said the client had viewed it, and your team was told. An agent looking doesn't count now; the client opening it still does. - Ticket emails: a picture of about 750 KB or more pasted into a reply, or into a ticket's details, left the email without its message - the picture went missing, and the words with it. The email has all of it now, whatever the picture's size. The same picture made a document come out empty in a client export, and a document template come out empty when it was exported or imported. - Ticket emails: a picture pasted into a reply, or into a ticket's details, now goes with the email as a picture attached inline, where the message shows it, rather than as data inside the message. Gmail, among others, showed no picture sent the old way. The mail queue also keeps each picture once, instead of a copy inside every email it sends. Admin > Mail Queue still shows the email with its pictures. @@ -127,6 +129,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u - Reports: `geography` in `reportCatalog()` (Clients & Documentation, `module_client`), `agent/reports/geography.php`. The outlines are `includes/maps/world.json`, `us.json` and `ca.json` - Natural Earth 1:50m (public domain), simplified and projected ahead of time (Equal Earth; Albers USA; Lambert conformal conic) to SVG paths in whole units, `{source, width, height, regions: {code: {name, d, dot}}}` keyed by ISO 3166-1 alpha-2 for countries and ISO 3166-2 (`US-PA`) for states and provinces, `dot` marking a place too small to see. In `functions/reports.php`: `reportGeoPlace()` reads a location's country (ITFlow's list through `settingsLocalizationArrays()`, the map's names, ISO codes and a few short forms; blank is `company_country`), state (postal code or name, for a country in `REPORT_GEO_MAPS`) and city into keys; `reportGeoLocations()`, `reportGeoGroup()`, `reportGeoMapHtml()` (inline SVG, each place's `--heat` from the square root of its share of the most, mixed into the accent as `.itflow-report-heat` is) and `reportGeoLegendHtml()`. Another country's states are a JSON file in the same shape and a line in `REPORT_GEO_MAPS`. - Reports: Export > PDF (`?export=pdf`) draws the report page as usual: `inc_report_layout.php` calls `reportPdfStart()`, which holds the output and registers `reportPdfFinish()` to make it a PDF as the page ends (or send it as it is after a fatal error, or when there is no `.itflow-report` on it). `ReportPdfWriter` (`functions/report_pdf.php`, loaded after TCPDF) reads the page's HTML back with DOMDocument and lays it out with TCPDF: `.itflow-report-head` as the title bar, `.itflow-report-stats` as a grid of cells, each `.card` as a section, tables with their columns sized by what is in them, `.itflow-report-heat` and `.itflow-dash-bars` shaded, the geography map redrawn from its paths with `ImageSVG()`, and Bootstrap's text, weight and badge classes turned into inline styles; `.d-print-none`, icons, avatars and meters are left out. Charts are drawn only in the browser, so `js/reports.js` draws each again off the page in the light theme (`drawChart()` now takes extra Chart options and returns the chart) and posts them as PNG data URLs in `charts[]`, in page order, with the theme's `accent`; the server keeps only PNGs. `reportTable()` lists every row, up to `EXPORT_PDF_MAX_ROWS`, for a PDF. `reportHeader()`'s Export menu has CSV (per table) then PDF, and takes `pdf` => false to leave the PDF out - it is out by default where `export` is false, and Client Review offers it once a client is picked. - Reports: `tax_package` in `reportCatalog()` (Finance, `module_financial`, `accounting`) and `agent/reports/tax_package.php`. `?start=` is the month the tax year starts (by `company_country` from `TAX_PACKAGE_START` when not given), `?year=` the year it starts in, `?rate=` the mileage rate and `?over=` the 1099 threshold (a US company with a January year; 600 before 2026, 2,000 from). The figures come from `reportIncomeByCategory()`, `reportExpensesByCategory()`, `taxReportSales()` on both bases, `taxReportPurchases()` and `accountBalanceSql()`; what was owed on an invoice at year end is `taxPackageOwedSql()`, which takes an invoice marked Paid that no payment covers as settled. Download package (`?export=package`) calls `reportPdfStart()` with a sender, so the page is drawn and made a PDF as usual and `taxPackageSend()` then builds the ZIP in `uploads/tmp` (removed when the request ends): the summary, the page's tables through the new `reportCsvData()` (what `reportCsv()` now sends), the Income, Expenses, Invoices and Trips registers, and `Receipts/` from `expenseReceiptPath()`. `reportPdfStart(callable $send = null)` can be called more than once, `reportPdfRequested()` is true for `pdf` and `package`, and `reportTable()` takes `pdf_whole` => false to keep its `limit` in a PDF. In report PDFs a table wider than the page now wraps only its text columns, down to their longest word, so figures stay on one line. +- `sendQueueEmail()` (`cron/mail_queue.php`) puts a calendar file in the message as its own `text/calendar` part (`$mail->Ical`) only for a meeting - `METHOD:REQUEST` or `CANCEL` with an `ORGANIZER` and an `ATTENDEE` - and attaches anything else as `invite.ics`. `createiCalStrCancel()` has neither, so a ticket's cancellation now goes as an attachment like its `PUBLISH` booking: Exchange Online makes the part into a meeting as it takes the message, and refused one with nobody in it. A PHPMailer exception from `send()` is thrown again with the SMTP server's last reply added (`getSMTPInstance()->getError()`), so `email_error` keeps it. ## [26.11.8] diff --git a/cron/mail_queue.php b/cron/mail_queue.php index bbbd445e3..0894772ef 100644 --- a/cron/mail_queue.php +++ b/cron/mail_queue.php @@ -282,13 +282,18 @@ function sendQueueEmail( $mail->Subject = $subject; $mail->Body = $html_body; - // A calendar invitation or cancellation goes in as its own text/calendar part + // A meeting invitation or cancellation goes in as its own text/calendar part // beside the HTML - the way calendar apps send them, and the only way Outlook - // shows one as a meeting rather than a file. PHPMailer only builds that part - // when there are no file attachments or pictures in the message, so anything - // else (and a published event to add) travels as an attached invite.ics. + // shows one as a meeting rather than a file. Only a meeting does: one with an + // organiser and attendees (an event's invitation). Microsoft 365 turns that part + // into a meeting as it takes the email, and refuses one with nobody in it - + // "data not accepted" - so a calendar file without them (a ticket's booking and + // its cancellation) is attached like a published event to add. PHPMailer only + // builds the part when there are no file attachments or pictures in the + // message either, so those also travel as an attached invite.ics. if (!empty($ics_str)) { - if (preg_match('/^METHOD:(REQUEST|CANCEL)\r?$/m', $ics_str) && empty($attachments_json)) { + $meeting = preg_match('/^METHOD:(REQUEST|CANCEL)\r?$/m', $ics_str) && preg_match('/^ORGANIZER[;:]/m', $ics_str) && preg_match('/^ATTENDEE[;:]/m', $ics_str); + if ($meeting && empty($attachments_json)) { $mail->Ical = $ics_str; $mail->AltBody = $mail->html2text($html_body); } else { @@ -328,7 +333,18 @@ function sendQueueEmail( } } - $mail->send(); + try { + $mail->send(); + } catch (Exception $e) { + // PHPMailer names the step that failed ("data not accepted"); the mail server's reply says why - keep it with the email + $smtp = $mail->getSMTPInstance()->getError(); + $detail = trim(preg_replace('/\s+/', ' ', (string) ($smtp['detail'] ?? ''))); + if ($detail !== '' && strpos($e->getMessage(), $detail) === false) { + $code = trim(($smtp['smtp_code'] ?? '') . ' ' . ($smtp['smtp_code_ex'] ?? '')); + throw new Exception($e->getMessage() . ' The mail server said: ' . ($code !== '' ? "$code " : '') . $detail, $e->getCode(), $e); + } + throw $e; + } return true; } diff --git a/functions/app.php b/functions/app.php index d550de767..eaee0b05e 100644 --- a/functions/app.php +++ b/functions/app.php @@ -897,6 +897,8 @@ function createiCalStr($datetime, $title, $description, $location, $uid = null) /* * Its cancellation. There is no stored copy of the original to reopen - the * match is made by UID - and the SEQUENCE must outrank the one it was sent with. + * Like the booking it has no organiser or attendees, so it goes with the email + * as an attached file to open, not as a meeting cancellation (cron/mail_queue.php). */ function createiCalStrCancel($datetime, $title, $uid) { global $config_timezone;