Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

PHP Error when replying to "New Message Alert" Email

I got an alert from osTicket for "New message appended to ticket #00019" etc.

I replied to this ticket directly from my email/Outlook.

I received the following bounce-back with a PHP error:

Server returned '554 5.3.0 < #5.3.0 x-unix; 
PHP Fatal error: Uncaught
exception 'ObjectNotUnique' with message 'One object was expected; however
multiple objects in the database matched the query. 
In fact, there are 2
matching objects.' in /var/www/osticket/upload/include/class.orm.php:1176 
#0 /var/www/osticket/upload/include/class.orm.php(545):
#1 /var/www/osticket/upload/include/class.thread.php(1188):
ThreadEntry->lookupByEmailHeaders(Array, false) 
/var/www/osticket/upload/include/ TicketApiController->processEmail() 
#4 /var/www/osticket/upload/api/pipe.php(26): PipeApiController::process() 
{main} thrown in /var/www/osticket/upload/include/class.orm.php on line

Anyone else encounter this, or know what this is saying, what is happening and why?


  • So you tried to respond as an agent to the ticket via email client? If so osTicket is not designed to do so.

  • I had read in another discussion by @ntozier that if an agent response to the ticket via email, that osTicket will automatically add the email to the ticket as an internal note.

  • Okay so it does; I completely forgot about that.

    So the error is saying the system looked up the email by it's headers in the database and there were more than one result. This fails because it's only expecting one result. So you need to figure out why there is more than one record with the same email headers as the email it's trying to process.

    Processes Email:
    Lookup ThreadEntry by `entryId`:

    I hope this helps! Cheers.
  • edited May 4
    @KevinTheJedi Thank you sir. Yeah I had figured thats what it was trying to tell me, but I'm not sure as to why it is saying that. Do you know where in the database it would store these specific values to lookup?

    I looked at the link you sent me; I see its checking "ThreadEntry" in the database.

    However, I'm not the most well-versed MySQL/PHP coder so can't pinpoint where the issue is taking place.

    I see in the database there are these tables setup which obviously pertain to this problem:

    • ost_thread_entry
    • ost_thread_entry_email
    Like you said its looking at the header of the emails and its saying two are identical and it breaks; but not entirely sure how I can locate this?

    Inside the "ost_thread_entry_email" table, this is what the contents look like:


    I see multiple strings that are identical, but I don't know if this is acceptable in this lookup table, as I saw in the github code you posted, there's a comment that says "All emails which do not appear to be part of an existing thread will always create new "Tickets". All other objects will need to be created via the web interface or the API". SO I don't know if its using that table to see whether tickets are part of the same thread or not, or if this is where my duplicate issue is taking place.

    Ok so I exported it as a Excel Spreadsheet. I found the "headers" entry inside the "ost_thread_entry_email" table.

    From left to right, the value categories are as follows:
    • ID
    • thread_entry_id
    • mid
    • headers
    This is a sample snapshot of my current entries, again left to right. Im confused here cause there are a BUNCH of "NULL" entries in the "headers" column, are these considered "duplicates"? Or is it checking the "mid" column?

  • Ok sorry @KevinTheJedi; I hadn't had my morning coffee yet and totally missed that second link you posted to the "Lookup ThreadEntry by 'entryId'".

    I found the duplicate entry finally. If you are experiencing the same issue, then your duplicate lies within the "ost_thread_entry_email" table, in the "mid" column.

    What I did is export the entire "ost_thread_entry_email" as a CSV (excel) file.

    I opened it up in Excel, did a find and delete on the trailing domains, e.g. Once I deleted the extra @domain strings, I then deleted the starting "<" character that sits infront of the long string.

    Then I selected the entire "mid" column, I then did a search for duplicates in excel.

    Go to the "Home" tab --> Conditional Formatting --> Highlight Cell Rules --> Duplicate Values

    It should then highlight which of the entries in the mid column are duplicates. Find them in the database, and delete one of the values.

    The reason I had to delete the trailing and starting "<" character, was that for whatever reason, with those still attached to the string, it was listing every entry as a duplicate. Once I removed those from the string values, it was showing me the actual correct identical duplicates from the column.

    I tested replying to a newly created ticket via email, and all is working. Error was removed and an internal note was posted in the ticket.

    You may close this discussion! Thank you guys for your help, much obliged.

  • @Pietro_Aretino

    I'm super glad you got this resolved!!

Sign In or Register to comment.