Contact alternate email (DB 4.4.1): one more address per contact in the contact window under Email, shown on their page, quick look and the Reach column, searched by the contacts, clients, tickets and global searches, exported and imported as Alternate Email and in the API as contact_email_alt, and recognized on incoming email as theirs - a new ticket as them at their client even with unknown senders off, and their reply by ticket number, conversation or subject - with the ticket's from line showing the address it came from while everything ITFlow sends still goes to their Email and neither address is copied in; the duplicate warning, Try an Email, Unprocessed Email and the ignored sender and routing rule warnings count it too, and the same-as-Email warning shows while typing (contactEmailSql(), contactHasEmail(), contactEmailMatchSql()); 26.12.4 changelog

This commit is contained in:
johnnyq
2026-12-02 13:36:49 -05:00
parent 8dae372d57
commit 2ad57e2865
31 changed files with 276 additions and 80 deletions

View File

@@ -204,3 +204,82 @@ function quickAddButton($type, $client_id = 0, $class = 'btn btn-outline-seconda
. (intval($client_id) ? ' data-quick-add-client="' . intval($client_id) . '"' : '')
. ' title="' . $titles[$type] . '" aria-label="' . $titles[$type] . '"><i class="fas fa-fw fa-plus"></i></button>';
}
/* ------------------------------------------------------------ Alternate email (4.4.1) */
/** Whether the 4.4.1 update has run - contacts have an alternate email (contact_email_alt). */
function contactEmailAltReady() {
global $mysqli;
static $ready = null;
if ($ready === null) {
$version = defined('CURRENT_DATABASE_VERSION') ? CURRENT_DATABASE_VERSION
: (string) (mysqli_fetch_row(mysqli_query($mysqli, "SELECT config_current_database_version FROM settings WHERE company_id = 1"))[0] ?? '0');
$ready = version_compare($version, '4.4.1', '>=');
}
return $ready;
}
/*
* SQL for a contact whose email or alternate email is $email (raw) - for finding who an email is from. $table, a table
* alias in front of the columns, as "c." for c.contact_email. An empty address finds nobody.
*/
function contactEmailSql($email, $table = '') {
$email = trim((string) $email);
if ($email === '') {
return '0';
}
$email_sql = escapeSql($email);
return contactEmailAltReady() ? "({$table}contact_email = '$email_sql' OR {$table}contact_email_alt = '$email_sql')" : "{$table}contact_email = '$email_sql'";
}
/** The alternate email as a SELECT column - '' before the 4.4.1 update. */
function contactEmailAltColumn() {
return contactEmailAltReady() ? 'contact_email_alt' : "'' AS contact_email_alt";
}
/** " OR contact_email_alt LIKE '%...%'" for a search, $like SQL-escaped as the search's own - '' before the 4.4.1 update. */
function contactEmailAltLikeSql($like, $table = '') {
return contactEmailAltReady() ? " OR {$table}contact_email_alt LIKE '%$like%'" : '';
}
/** Whether $email (raw) is the contact's ($row: contact_email, contact_email_alt) - their email or their alternate one, any case. */
function contactHasEmail(array $row, $email) {
$email = strtolower(trim((string) $email));
if ($email === '') {
return false;
}
return strtolower(trim((string) ($row['contact_email'] ?? ''))) === $email || strtolower(trim((string) ($row['contact_email_alt'] ?? ''))) === $email;
}
/*
* An alternate email as posted, trimmed - an address, at most 200 characters, and not the contact's own email ($email, in any
* case) - or '' for none.
*/
function contactEmailAltClean($alt, $email = '') {
$alt = trim((string) $alt);
if ($alt === '' || mb_strlen($alt) > 200 || !filter_var($alt, FILTER_VALIDATE_EMAIL) || strtolower($alt) === strtolower(trim((string) $email))) {
return '';
}
return $alt;
}
/*
* SQL for a contact with an address that $match takes - an address, or a domain and its subdomains, as an ignored sender
* or an email routing rule has it - by their email or their alternate one. Any case. For the warnings on saving one.
*/
function contactEmailMatchSql($match) {
$match = strtolower(trim((string) $match));
if ($match === '') {
return '0';
}
$parts = [];
foreach (contactEmailAltReady() ? ['contact_email', 'contact_email_alt'] : ['contact_email'] as $column) {
if (strpos($match, '@') !== false) {
$parts[] = "LOWER($column) = '" . escapeSql($match) . "'";
} else {
$like = escapeSql(str_replace(['\\', '%', '_'], ['\\\\', '\\%', '\\_'], $match));
$parts[] = "LOWER($column) LIKE '%@$like' OR LOWER($column) LIKE '%.$like'";
}
}
return '(' . implode(' OR ', $parts) . ')';
}

View File

@@ -76,6 +76,7 @@ function getExportColumns($export_type) {
'contact_title' => ['label' => 'Title'],
'contact_department' => ['label' => 'Department'],
'contact_email' => ['label' => 'Email', 'weight' => 2],
'contact_email_alt' => ['label' => 'Alternate Email', 'weight' => 2],
'contact_phone' => ['label' => 'Phone', 'format' => 'phone'],
'contact_extension' => ['label' => 'Ext'],
'contact_mobile' => ['label' => 'Mobile', 'format' => 'phone'],

View File

@@ -96,6 +96,7 @@ function importKinds() {
'title' => $f('Title', ['Job Title'], ['example' => 'Office Manager']),
'department' => $f('Department', ['Department Name']),
'email' => $f('Email', ['Email Address', 'E-mail'], ['example' => 'jordan@example.com']),
'email_alt' => $f('Alternate Email', ['Alt Email', 'Alternate Email Address', 'Secondary Email', 'Other Email', 'Personal Email', 'Email 2'], ['example' => 'jordan@personal.example', 'about' => 'Email from it is theirs too']),
'phone' => $f('Phone', ['Office Phone', 'Work Phone', 'Phone Number'], ['example' => '412-555-0100']),
'extension' => $f('Ext', ['Extension', 'Office Extension']),
'mobile' => $f('Mobile', ['Mobile Phone', 'Cell', 'Cell Phone']),
@@ -629,6 +630,14 @@ function importContactRow(array $row, $client_id, $existing_id, $write) {
$set[] = 'contact_email = ' . importSqlText($value);
}
}
// The alternate email - an address, and not their Email (functions/contact.php)
if (contactEmailAltReady() && ($value = $give('email_alt')) !== null) {
if ($value !== '' && contactEmailAltClean($value, (string) ($give('email') ?? '')) === '') {
$notes[] = importLeftNote('Alternate Email', $value, filter_var($value, FILTER_VALIDATE_EMAIL) ? 'is the same as their Email' : "isn't an email address", $up);
} else {
$set[] = 'contact_email_alt = ' . importSqlText($value, 200);
}
}
foreach (['phone', 'mobile'] as $key) {
if (($value = $give($key)) !== null) {
$set[] = importPhoneSql($value, "contact_$key");

View File

@@ -104,12 +104,12 @@ function mailIgnoreReach($match) {
}
$match_sql = escapeSql($match);
if (strpos($match, '@') !== false) {
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL AND LOWER(contact_email) = '$match_sql'"))[0] ?? 0);
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL AND " . contactEmailMatchSql($match)))[0] ?? 0);
return $out;
}
$like = escapeSql(str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $match));
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL
AND (LOWER(contact_email) LIKE '%@$like' OR LOWER(contact_email) LIKE '%.$like')"))[0] ?? 0);
// Their email or their alternate one (functions/contact.php)
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL AND " . contactEmailMatchSql($match)))[0] ?? 0);
$sql = mysqli_query($mysqli, "SELECT DISTINCT client_name FROM domains JOIN clients ON client_id = domain_client_id
WHERE domain_archived_at IS NULL AND client_archived_at IS NULL AND (LOWER(domain_name) = '$match_sql' OR LOWER(domain_name) LIKE '%.$like') ORDER BY client_name LIMIT 5");
while ($sql && ($row = mysqli_fetch_row($sql))) {

View File

@@ -229,12 +229,12 @@ function mailRouteReach($match, $client_id = 0) {
$match_sql = escapeSql($match);
$other = "AND contact_client_id <> $client_id";
if (strpos($match, '@') !== false) {
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL AND LOWER(contact_email) = '$match_sql' $other"))[0] ?? 0);
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL $other AND " . contactEmailMatchSql($match)))[0] ?? 0);
return $out;
}
$like = escapeSql(str_replace(['\\', '%', '_'], ['\\\\', '\%', '\_'], $match));
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL $other
AND (LOWER(contact_email) LIKE '%@$like' OR LOWER(contact_email) LIKE '%.$like')"))[0] ?? 0);
// Their email or their alternate one (functions/contact.php)
$out['contacts'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM contacts WHERE contact_archived_at IS NULL $other AND " . contactEmailMatchSql($match)))[0] ?? 0);
$sql = mysqli_query($mysqli, "SELECT DISTINCT client_name FROM domains JOIN clients ON client_id = domain_client_id
WHERE domain_archived_at IS NULL AND client_archived_at IS NULL AND client_id <> $client_id AND (LOWER(domain_name) = '$match_sql' OR LOWER(domain_name) LIKE '%.$like')
ORDER BY client_name LIMIT 5");

View File

@@ -193,7 +193,7 @@ function globalSearchGroups($terms, $deep) {
'select' => 'contact_id, contact_name, contact_title, contact_email, contact_photo, contact_client_id, client_name',
'from' => 'contacts LEFT JOIN clients ON contact_client_id = client_id',
'where' => "contact_archived_at IS NULL
AND (contact_name LIKE '%$like%' OR contact_email LIKE '%$like%' OR contact_title LIKE '%$like%' $contact_phone_match
AND (contact_name LIKE '%$like%' OR contact_email LIKE '%$like%'" . contactEmailAltLikeSql($like) . " OR contact_title LIKE '%$like%' $contact_phone_match
" . tagSearchSql('contact', $like, 'contacts.contact_id') . ")",
'scope' => 'contact_client_id',
'tags' => ['contact', 'contacts.contact_id'],

View File

@@ -147,15 +147,17 @@ function ticketMailDecide(array $in) {
$domain_row = null;
$contact = null;
if (!$visitor) {
$contact = $route['contact'] ? $route['contact'] + ['client_name' => $route_client['client_name']] : (mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_client_id, client_name
FROM contacts LEFT JOIN clients ON client_id = contact_client_id WHERE contact_client_id = " . intval($route_client['client_id']) . " AND contact_email = '$from_sql' AND contact_archived_at IS NULL LIMIT 1")) ?: null);
$contact = $route['contact'] ? $route['contact'] + ['client_name' => $route_client['client_name']] : (mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, " . contactEmailAltColumn() . ", contact_client_id, client_name
FROM contacts LEFT JOIN clients ON client_id = contact_client_id WHERE contact_client_id = " . intval($route_client['client_id']) . " AND " . contactEmailSql($from) . " AND contact_archived_at IS NULL LIMIT 1")) ?: null);
}
}
// A routed email's sender is answered and copied in only as the ticket's contact - who they are, or who they will be as a
// new contact at a client's domain: a system's address isn't sent "we have your email" and every reply after it
$sender_is_contact = $contact && strtolower((string) $contact['contact_email']) === $from;
// The sender is the contact by their email or their alternate one (contactHasEmail(), functions/contact.php) - from their
// alternate one, or someone else's for a rule's contact, the ticket says the address it came from
$sender_is_contact = $contact && contactHasEmail($contact, $from);
$out['quiet'] = $route && !($visitor || $sender_is_contact || ($domain_row && $forged === ''));
if ($contact && !$sender_is_contact && !$visitor) {
if ($contact && !$visitor && strtolower(trim((string) $contact['contact_email'])) !== $from) {
$out['sender'] = ['name' => (string) ($in['from_name'] ?? ''), 'email' => $from];
}
@@ -176,7 +178,7 @@ function ticketMailDecide(array $in) {
}
if ($out['similar']) {
$similar = $out['similar'];
$theirs = !$visitor && !$forward && !$out['quiet'] && (($contact && !$out['sender'] && intval($contact['contact_id']) === intval($similar['ticket_contact_id']))
$theirs = !$visitor && !$forward && !$out['quiet'] && (($contact && $sender_is_contact && intval($contact['contact_id']) === intval($similar['ticket_contact_id']))
|| ($from !== '' && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM ticket_ccs WHERE ticket_cc_ticket_id = " . intval($similar['ticket_id']) . " AND ticket_cc_email = '$from_sql' LIMIT 1"))));
if ($theirs) {
$step('The same subject as an open ticket of theirs from the last week?', 'Yes - ' . ticketReference($similar));
@@ -197,7 +199,8 @@ function ticketMailDecide(array $in) {
// 4. A contact - a website form sent as one (an address made a contact before) is that contact's client's, from its visitor
if ($contact) {
$others = $picked['others'] ? ' - and at ' . implode(', ', $picked['others']) . ' too, so it goes to ' . ($contact['client_name'] ?? 'no client') . ', ' . $picked['why'] : '';
$step('A contact\'s address?', 'Yes - ' . $contact['contact_name'] . ($contact['client_name'] !== null ? ', ' . $contact['client_name'] : '') . $others);
$step('A contact\'s address?', 'Yes - ' . $contact['contact_name'] . ($contact['client_name'] !== null ? ', ' . $contact['client_name'] : '')
. (strtolower(trim((string) $contact['contact_email'])) !== $from ? ' - their alternate email' : '') . $others);
return ['action' => 'ticket', 'client_id' => intval($contact['contact_client_id']), 'client_name' => $contact['client_name'] ?? null,
'contact' => $visitor ? null : $contact, 'picked' => $visitor ? [] : $picked] + $out;
}

View File

@@ -234,12 +234,14 @@ function ticketMailSubjectTicket($subject) {
function ticketMailCopiedCcs($ticket_id, array $addresses, $sender) {
global $mysqli;
$ticket_id = intval($ticket_id);
$contact_email = strtolower(trim((string) (mysqli_fetch_row(mysqli_query($mysqli, "SELECT contact_email FROM tickets
JOIN contacts ON contact_id = ticket_contact_id WHERE ticket_id = $ticket_id"))[0] ?? '')));
$contact = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_email, " . contactEmailAltColumn() . " FROM tickets
JOIN contacts ON contact_id = ticket_contact_id WHERE ticket_id = $ticket_id")) ?: [];
$contact_email = strtolower(trim((string) ($contact['contact_email'] ?? '')));
$contact_email_alt = strtolower(trim((string) ($contact['contact_email_alt'] ?? '')));
$sender = strtolower(trim((string) $sender));
$emails = [];
foreach (ticketCcEmails($addresses) as $email) {
if ($email === $sender || $email === $contact_email || emailOwnAddress($email) || emailOwnDomain($email)
if ($email === $sender || $email === $contact_email || ($contact_email_alt !== '' && $email === $contact_email_alt) || emailOwnAddress($email) || emailOwnDomain($email)
|| preg_match('/do[\W_]*not[\W_]*reply|no[\W_]*reply/i', $email)) {
continue;
}
@@ -252,11 +254,12 @@ function ticketMailCopiedCcs($ticket_id, array $addresses, $sender) {
}
/*
* The contact an email from $email is from, when it is one - ['contact' => row (contact_id, contact_name, contact_email,
* contact_client_id, client_name) or null, 'others' => the other clients it is a contact at, [client_id => name],
* 'why' => how the one was picked]. An address can be a contact at more than one client - someone who works for two,
* a shared mailbox - and its email went to whichever the database gave first. Now: the client whose domain it is
* ($domain, Domains), else the one they last raised a ticket at, else the first they were added to.
* The contact an email from $email is from, when it is one - their Email or their alternate one - ['contact' => row
* (contact_id, contact_name, contact_email, contact_email_alt, contact_client_id, client_name) or null, 'others' => the
* other clients it is a contact at, [client_id => name], 'why' => how the one was picked]. An address can be a contact at
* more than one client - someone who works for two, a shared mailbox - and its email went to whichever the database gave
* first. Now: the client whose domain it is ($domain, Domains), else a contact whose Email it is over one whose alternate
* it is, else the one they last raised a ticket at, else the first they were added to.
*/
function ticketMailSenderContact($email, $domain = '') {
global $mysqli;
@@ -268,12 +271,12 @@ function ticketMailSenderContact($email, $domain = '') {
$email_sql = escapeSql($email);
$domain_sql = escapeSql(strtolower(trim((string) $domain)));
$rows = [];
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_client_id, client_name,
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, " . contactEmailAltColumn() . ", contact_client_id, client_name,
(SELECT 1 FROM domains WHERE domain_client_id = contact_client_id AND domain_name = '$domain_sql' AND domain_archived_at IS NULL LIMIT 1) AS at_domain,
(SELECT MAX(ticket_created_at) FROM tickets WHERE ticket_contact_id = contact_id) AS last_ticket
FROM contacts LEFT JOIN clients ON client_id = contact_client_id
WHERE contact_email = '$email_sql' AND contact_archived_at IS NULL
ORDER BY at_domain DESC, last_ticket DESC, contact_id");
WHERE " . contactEmailSql($email) . " AND contact_archived_at IS NULL
ORDER BY at_domain DESC, contact_email = '$email_sql' DESC, last_ticket DESC, contact_id");
while ($row = mysqli_fetch_assoc($sql)) {
$rows[] = $row;
}
@@ -320,7 +323,7 @@ function ticketMailSenderContactNote($ticket_id, $email, array $picked) {
function ticketMailClientAddresses($ticket_id, array $addresses) {
global $mysqli;
$ticket_id = intval($ticket_id);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_client_id, contact_email FROM tickets LEFT JOIN contacts ON contact_id = ticket_contact_id WHERE ticket_id = $ticket_id"));
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_client_id, contact_email, " . contactEmailAltColumn() . " FROM tickets LEFT JOIN contacts ON contact_id = ticket_contact_id WHERE ticket_id = $ticket_id"));
if (!$row) {
return [];
}
@@ -331,9 +334,9 @@ function ticketMailClientAddresses($ticket_id, array $addresses) {
continue;
}
$email_sql = escapeSql($email);
if (strtolower(trim((string) $row['contact_email'])) === $email
if (contactHasEmail($row, $email)
|| mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM ticket_ccs WHERE ticket_cc_ticket_id = $ticket_id AND ticket_cc_email = '$email_sql' LIMIT 1"))
|| ($client_id && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM contacts WHERE contact_email = '$email_sql' AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))) {
|| ($client_id && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM contacts WHERE " . contactEmailSql($email) . " AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))) {
$found[] = $email;
}
}

View File

@@ -108,9 +108,12 @@ function ticketMailTryOutcome(array $decision, $from_email, $auto_reply = false)
$contact_text . 'The subject is its subject and the email its details. ' . $route_text . ($decision['quiet'] ? '' : ' ' . ticketMailTryNoReply($from_email)) . $linked];
}
if ($contact) {
// From their alternate email - answered at their Email, where everything ITFlow sends goes
$alternate = strtolower(trim((string) $contact['contact_email'])) !== $from_email;
return ['fa-plus-circle', 'success', 'A new ticket for ' . ($decision['client_name'] ?? 'no client'),
'From ' . $contact['contact_name'] . ', with the subject as its subject and the email as its details. ' . (!empty($decision['picked']['others']) ? 'A note on it names the other clients they are a contact at. ' : '')
. ($route_text !== '' ? $route_text . ' ' : '') . ticketMailTryNoReply($from_email) . $linked];
'From ' . $contact['contact_name'] . ($alternate ? ', at their alternate email' : '') . ', with the subject as its subject and the email as its details. ' . (!empty($decision['picked']['others']) ? 'A note on it names the other clients they are a contact at. ' : '')
. ($route_text !== '' ? $route_text . ' ' : '') . ticketMailTryNoReply((string) $contact['contact_email'])
. ($alternate ? ' That goes to their Email, ' . $contact['contact_email'] . ', as all their ticket email does.' : '') . $linked];
}
if ($decision['new_contact']) {
return ['fa-plus-circle', 'success', 'A new contact and ticket for ' . $decision['client_name'],
@@ -150,7 +153,7 @@ function ticketMailTryRoute(array $route, $quiet) {
function ticketMailTryReply($from_email, $ticket_id) {
global $mysqli;
$from_sql = escapeSql($from_email);
$ticket = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id, contact_email, contact_name, client_name
$ticket = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_client_id, ticket_contact_id, contact_email, " . contactEmailAltColumn() . ", contact_name, client_name
FROM tickets LEFT JOIN contacts ON contact_id = ticket_contact_id LEFT JOIN clients ON client_id = ticket_client_id
WHERE ticket_id = " . intval($ticket_id) . " LIMIT 1"));
if (!$ticket) {
@@ -159,8 +162,9 @@ function ticketMailTryReply($from_email, $ticket_id) {
$reference = ticketReference($ticket);
$on = $reference . ' - ' . $ticket['ticket_subject'] . ($ticket['client_name'] !== null ? ' (' . $ticket['client_name'] . ')' : '');
$client_id = intval($ticket['ticket_client_id']);
$known = (strtolower((string) $ticket['contact_email']) === $from_email && $from_email !== '')
|| ($client_id && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM contacts WHERE contact_email = '$from_sql' AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))
$is_contact = intval($ticket['ticket_contact_id']) && contactHasEmail($ticket, $from_email);
$known = $is_contact
|| ($client_id && mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM contacts WHERE " . contactEmailSql($from_email) . " AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))
|| mysqli_num_rows(mysqli_query($mysqli, "SELECT 1 FROM ticket_ccs WHERE ticket_cc_ticket_id = " . intval($ticket['ticket_id']) . " AND ticket_cc_email = '$from_sql' LIMIT 1"));
if (intval($ticket['ticket_status']) === TICKET_STATUS_CLOSED) {
return ['fa-ban', 'warning', "A note on $reference - it is closed",
@@ -168,10 +172,10 @@ function ticketMailTryReply($from_email, $ticket_id) {
. ($known ? '. The sender is told it is closed, and how to raise a new ticket.' : '. The sender isn\'t a contact or CC, so nobody is told - a guessed number would tell them its subject.')];
}
$reopens = ticketMailTryReopens($ticket['ticket_status']);
if (strtolower((string) $ticket['contact_email']) === $from_email && $from_email !== '') {
return ['fa-reply', 'success', "A reply on $on", 'From its contact, ' . $ticket['contact_name'] . ', as the client\'s reply. ' . $reopens];
if ($is_contact) {
return ['fa-reply', 'success', "A reply on $on", 'From its contact, ' . $ticket['contact_name'] . (strtolower(trim((string) $ticket['contact_email'])) !== $from_email ? ' - their alternate email' : '') . ', as the client\'s reply. ' . $reopens];
}
$other = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE contact_email = '$from_sql' AND contact_client_id = $client_id LIMIT 1"));
$other = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE " . contactEmailSql($from_email) . " AND contact_client_id = $client_id LIMIT 1"));
if ($other) {
return ['fa-reply', 'success', "A reply on $on", 'From ' . $other['contact_name'] . ', another of the client\'s contacts, as the client\'s reply. ' . $reopens];
}