This is a pro-Israeli website giving the “mistaken identity” viewpoint. And here is a website put up by the surviving sailors. As you can see, those two accounts vary greatly. It is very difficult, if not impossible, to find any online sources that are not heavily biased one way or the other.
From what I’ve been able to find out, this much true:
The US informed Israel that it had no ships within 100 miles of the coast, and that the ship went in much closer than it was supposed to do despite radio warnings from the US command (however, the Israelis had spotted the ship a day or two earlier, and identified it as American, but then apparently lost it between then and the attack).
US radio intercepts also have the Israelis referring to the ship and possible survivors as “Egyptian” (although, of course, the Israelis could have done that knowing that they were likely to be eavesdropped on).
The Israelis say that their pilots did eventually realise that the ship wasn’t what they thought it was (they say that they thought it was Soviet when they realised it wasn’t Egyptian), and that the attack was called off and the information was radioed to the torpedo boats, but that the boats for some reason either didn’t get the message or ignored it. Both the American ship and the Israeli torpedo boats did try communicating by Morse code, but the Americans couldn’t see the Israeli messages clearly and the Israelis say that they misunderstood the Americans. The Americans did open the second phase of hostilities by opening fire on the Israeli boats (which of course they would do if they thought that they were under attack yet again), after which the boats launched torpedoes.
There does appear to have been a whole lot of miscommunication and lack of communication on both the US and Israeli sides. Overall, I’d say that there’s no way that any of us here can really say positively whether it was intentional or accidental, since we don’t have access to the actual records and recordings, and haven’t talked with all the surviving people who were involved.