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

@@ -438,7 +438,7 @@ function addReply($from_email, $date, $subject, $ticket_id, $message, $attachmen
$from_email_esc = mysqli_real_escape_string($mysqli, $from_email);
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_contact_id, ticket_client_id, contact_email, client_name
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_status, ticket_contact_id, ticket_client_id, contact_email, " . contactEmailAltColumn() . ", client_name
FROM tickets
LEFT JOIN contacts on tickets.ticket_contact_id = contacts.contact_id
LEFT JOIN clients on tickets.ticket_client_id = clients.client_id
@@ -459,10 +459,11 @@ function addReply($from_email, $date, $subject, $ticket_id, $message, $attachmen
$reply_by = 0;
if ($no_sender) {
$who = 'stranger';
} elseif (trim((string) $row['contact_email']) !== '' && strcasecmp(trim((string) $row['contact_email']), stripslashes($from_email)) === 0) {
} elseif (intval($row['ticket_contact_id']) && contactHasEmail($row, stripslashes($from_email))) {
// The ticket's contact - from their email or their alternate one
$who = 'contact';
$reply_by = intval($row['ticket_contact_id']);
} elseif ($client_id && ($contact_row = mysqli_fetch_row(mysqli_query($mysqli, "SELECT contact_id FROM contacts WHERE contact_email = '$from_email_esc' AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))) {
} elseif ($client_id && ($contact_row = mysqli_fetch_row(mysqli_query($mysqli, "SELECT contact_id FROM contacts WHERE " . contactEmailSql(stripslashes($from_email)) . " AND contact_client_id = $client_id AND contact_archived_at IS NULL LIMIT 1")))) {
$who = 'contact';
$reply_by = intval($contact_row[0]);
} elseif ($agent_row = mysqli_fetch_row(mysqli_query($mysqli, "SELECT user_id FROM users WHERE user_email = '$from_email_esc' AND user_type = 1 AND user_status = 1 AND user_archived_at IS NULL LIMIT 1"))) {