Departments and email in

Set up support departments and custom ticket fields, and turn incoming email into tickets with an IMAP mailbox or a mail-server pipe.

A department is a queue that tickets are sorted into, such as Sales or Technical support. Each department can have one email address. Mail sent to that address becomes tickets in that department, and replies from your staff go out with that address as the Reply-To. Only administrators manage departments and ticket fields. Turn on support first; see Support tickets.

Add a department#

Open Departments and select Add department.

Field What it does
Name and Description Customers see both when they choose a department.
Link name Used in links. Made from the name if blank.
Sort order Lower numbers come first.
Listed or Unlisted Listed departments appear on the customer's new ticket form. Unlisted ones are hidden there, but staff can still open tickets in them and email to the address still arrives. A customer can also reach an unlisted department by a direct link.
Active Inactive departments accept no new tickets. Existing tickets stay readable.
Staff Members see this department's tickets and can be assigned to them.
Department email The address customers write to. It must be unique, and is matched case-insensitively.
Acknowledge new tickets by email On by default. Sends the customer a short confirmation with their ticket number.

The list shows each department's email, whether it is pulled over IMAP or has an error, how many staff and tickets it has, and its status. A department that still has tickets cannot be deleted. Move the tickets or mark the department Inactive instead.

Custom ticket fields#

Open Ticket fields and select Add field to ask extra questions on the ticket form, such as a domain name or order number.

Field What it does
Label What people see above the input.
Type Single line, Multiple lines, Choice, Yes / no, Number or Date.
Applies to All departments, or one.
Choices For the Choice type, one option per line.
Help text Shown under the input.
Required The ticket cannot be submitted without an answer.
Staff only Filled in and seen by staff only, never by the customer.
Active Inactive fields are hidden from new tickets. Answers already given stay.
Key and Sort order The key is made from the label if blank.

Deleting a field removes the question, but answers already given stay on their tickets.

Getting email in#

You have two ways to turn email into tickets.

Option 1: pull from a mailbox (IMAP)#

In the department form, tick Pull mail from a mailbox and fill in:

Field Notes
Server and Port For example imap.example.com, port 993. The port defaults to 993 if left blank.
Encryption SSL/TLS (993), STARTTLS (143) or None. Do not use None outside a private network.
Folder Defaults to INBOX.
Username and Password The password is stored encrypted. Leave the field blank when editing to keep the saved one.
After a message is imported Mark it as read, or Delete it from the mailbox.
Check the server's certificate Leave on. Turn off only for a certificate you trust that is self-signed.

Mail read from a mailbox belongs to that department. Use Test connection after saving the department: it signs in with what is typed in the form (using the saved password if the field is blank), opens the folder and reports the unread count. It does not read or change mail, and saves nothing.

Tidemark Billing checks mailboxes with the tickets:fetch command, which runs every minute from the scheduler, so the usual cron entry for schedule:run is all you need. See Cron job. Each run reads up to 50 unread messages per mailbox, oldest first. A message is marked read (or deleted) once it has been dealt with, including ones that were ignored or were duplicates. If handling a message fails, it stays unread so the next run retries it, and the department shows the error. You can run it by hand:

php artisan tickets:fetch --department=sales

The last failed check shows as a red notice on the department page. Common causes when a mail client works but the sign-in fails:

  • The mail server limits sign-ins by IP address or has blocked your server's address after earlier failures.
  • The provider needs an app password for IMAP, or has IMAP switched off for the mailbox.
  • The login name is not the full email address.

Sign-in uses a username and password only. OAuth2 sign-in is not supported. Gmail and Google Workspace need IMAP turned on and an app password; many Microsoft 365 tenants disable basic-authentication IMAP. If you cannot use a password, use the pipe or forward the mail to a mailbox elsewhere.

Option 2: pipe mail to a program#

If your mail server can hand each message to a command, tickets appear immediately and no polling is involved. The command is:

php artisan tickets:pipe --department=support

It reads one raw message from standard input. Without --department, the recipient addresses decide the department: it looks at Delivered-To, X-Original-To, Envelope-To, then To and Cc, against the active departments' email addresses. Nothing from the message is printed.

Exit code Meaning
0 Handled. A ticket or reply was created, or the mail was deliberately dropped (duplicate, automatic mail, locked ticket, rejected sender). No bounce is sent.
67 Unknown recipient: no department uses the address. The sender gets a bounce.
75 Temporary failure, for example support is off or the database is down. The mail server keeps the message and retries.

Examples (adjust the paths to your server). In cPanel, go to Email → Forwarders, add a forwarder for the department address, choose Advanced Options → Pipe to a program and enter:

|/usr/local/bin/php /home/example/billing/artisan tickets:pipe

Use the PHP binary that matches the version Tidemark Billing runs on. The user running the pipe must be able to read the application's .env file and write to storage/.

For Postfix, add a line to /etc/aliases and run newaliases:

support: "|/usr/bin/php /var/www/billing/artisan tickets:pipe --department=support"

Exim, qmail and procmail work the same way: pipe the message in and honour the exit code.

How replies attach to tickets#

Every email about a ticket carries a tag in the subject such as [TKT-00001], a message ID that includes the ticket, and the line "##- Please type your reply above this line -##". When mail arrives, it is matched to a ticket in this order:

  1. The In-Reply-To or References headers name a message we sent or stored.
  2. A [TKT-00001] tag in the subject, using your ticket prefix.
  3. Otherwise a new ticket is opened.

Everything from the marker line down, quoted lines starting with > and a trailing "On ... wrote:" block are removed, so the ticket shows only what is new. HTML-only mail is converted to plain text.

Rules that protect you#

Anyone can type a ticket number in a subject, so a message is added to an existing ticket only when the sender is the ticket's requester or a login of the ticket's client. Anyone else gets a new ticket. Staff are never treated as staff by email; staff answer in the admin.

These are also applied to every message:

  • Mail with a Message-ID already seen is ignored as a duplicate.
  • Automatic mail is dropped: Auto-Submitted other than no, Precedence: bulk, junk or list, X-Autoreply, X-Autorespond, List-Id, an empty Return-Path, and senders such as mailer-daemon, postmaster and no-reply addresses.
  • Mail from any department's own address is dropped, so two departments cannot answer each other forever.
  • A locked ticket ignores replies. A reply to a closed ticket reopens it.
  • With Reject email from people without a client account on, mail from unknown addresses does not open tickets.

Email From addresses can be forged. Turn on SPF, DKIM and DMARC checks at your mail gateway or provider and reject failing mail before it reaches Tidemark Billing.

Was this article helpful?
Last updated 10 Nov 2026
Powered by Tidemark Billing