If the DM rules that the source of the temporary hit points is the iron golem's extraordinary ability magic immunity, a creature like an an iron golem (Monster Manual 136-7) can't gain nigh-infinite temporary hit points in the way the question describes That ability, in part, says
A magical attack that deals fire damage breaks any slow effect on the golem and heals 1 point of damage for each 3 points of damage the attack would otherwise deal. If the amount of healing would cause the golem to exceed its full normal hit points, it gains any excess as temporary hit points. For example, an iron golem hit by a fireball gains back 6 hit points if the damage total is 18 points. (137)
And the Rules Compendium on Temporary Hit Points, in part, says
Temporary hit points gained from multiple applications of the same effect don’t stack. Instead, the highest number of temporary hit points gained from that effect apply.
This ruling is similar to a ruling made by the FAQ in the exchange beginning Do temporary hit points from two applications of the same effect stack? (113). (Note that some folks have issues with the FAQ (see here) and with the RC (see here).)
Thus were an iron golem to have gained temporary hp due to its magic immunity from one fireball then gained temporary hp from another fireball, only the temporary hp from the fireball that provided the most temporary hp would apply.
However, the Player's Handbook on Temporary Hit Points (146) doesn't mention these restrictions on temporary hp. While it can be argued that temporary hp are a bonus of sorts and should not, if from the same source—like a golem's magic immunity—, "combine for cumulative effect" as per the PH glossary's definition of stack (313), that's not often an argument that's entertained.
Therefore in a campaign wherein the DM doesn't use the RC or the FAQ, the DM may rule that, for example, the source of the iron golem's temporary hp is, instead, an individual fireball and that each fireball grants the iron golem temporary hp on top of any previous temporary hp and that an iron golem can gain nigh-infinite temporary hp from repeated exposure to magical fire attacks, no matter the kind.
Such a ruling, though, cascades mightily throughout the game, and the PCs may, for example, eventually end up facing a vampire (MM 250-3) that's used its supernatural ability energy drain many times in the hour before encountering the PCs, each new use of its energy drain ability possibly being considered a different source of temporary hp. With this in mind, this DM and this player recommends hewing with the FAQ and the RC on this issue.