The question is flawed to begin with. For most particles, mass and energy are one and the same and can be exchanged for each other. This is not the case with photons, however. The photons energy is determined only by it's wavelength as explained by the expression E=hc/λ.
the question isnt flawed. if energy has mass, the photons (energy) have mass.
if energy only possesses mass when in aggregate with another substance, then energy itself never possesses mass. energy can only be encompassed by mass, never made up of it.
but i think the case is that energy, being extended, takes up space, in of that there is actually something there in that space and not just a concept of a thing, there is some observable entity in that space, and that entity is made of something. thus, energy, being made of something extended, being extended itself, does possess "Mass" in the purest sense (AKA total amount of material that makes an object) because it is made up of some quantity of something. even photons are made of something, and thus have "mass" in this sense.. = they have an amount of substance which makes them up.
i probably should have brought this up the very first time we ever touched on this issue. well, now that i think about it i was actually trying to play a game of "got ya!" by making this assertion. but i guess i needed to fill in the gaps of my assertion with more information as to lead you down the path i was on.