Leap from photon gas energy distribution to black body radiation? I remember considering in class in college, the case of a photon gas trapped in a d-dimensional box as a subject of interest, whose energy distribution, heat capacity, etc. should be calculated. 
This momentum/energy distribution was then related to that emitted by a black body - that up to a constant factor, they are one in the same.
I could understand the argument that making a small hole in such a box would constitute a "black body", as the hole can't reflect back light impinging on it, but I can't see how to make the conclusion that this is the exact same distribution. Shouldn't the atomic structure of matter be brought into account as well, or is it considered "hollow" on sufficiently large scales?  
 A: Let us compare thermal equilibrium radiation you have described and the black body radiation.
Take an object B at thermal equilibrium (not necessarily a black body), and denote with $\varepsilon(\lambda)$ the fraction of radiation of wavelength $\lambda$ it absorbs.
Thus if $a(\lambda)$ of radiation of the wavelength $\lambda$ falls on B, it absorbs
$\varepsilon(\lambda)a(\lambda)$ and reflects the rest.
Imagine a box with a small hole you've just described, and a close this hole with B:

Assume, that B has the same temperature, as the radiation in the box (or, rather, take a box with the same temperature as B). Then the system is at thermal equilibrium. Thus absorbing $\varepsilon(\lambda)a_0(\lambda)$ it has to emit the same amount, i.e. $\varepsilon(\lambda)a_0(\lambda)$ (here $a_0(\lambda)$ is the thermal equilibrium radiation you have described and computed in class: radiation, going from the hole).
Object is indeed called a black body if it absorbs all the radiation, falling on it, i.e. if $\varepsilon(\lambda)=1$. From the "thermal equilibrium" argument above you see, that it emits $\varepsilon(\lambda)a(\lambda)=a_0(\lambda)$, i.e. black body radiation coincides with thermal equilibrium radiation and we can now call $a_0(\lambda)$ by the words "thermal radiation".
As a bonus, if the body B is not black, it still has to emit $\varepsilon(\lambda) a_0(\lambda)$. This is called "Kirchhoff's law of thermal radiation".
A: The role of the atomic structure of the black body has its importance, as it will determine how the light is absorbed. And a black body is defined as matter that absorbs everything. However, matter will always absorb a little bit, and reflect or disperse the rest. Having a little hole allows for light to bounce many times after entering, every time absorbing part of the photons. After an infinite number of bounces, you can suppose everything has been absorbed, whatever the atomic structure is. You just need the matter to absorb a fraction of the light at each bounce.
A: This site might help in clearing up the concepts, which are not simple. In the link, click "heat and thermodynamics" and then " radiation" and then "black body" on the right column to get the options shown in the image. Unfortunately the site does not link back to individual pages. :(. 

Clicking on the main line,

Blackbody radiation" or "cavity radiation" refers to an object or system which absorbs all radiation incident upon it and re-radiates energy which is characteristic of this radiating system only, not dependent upon the type of radiation which is incident upon it. The radiated energy can be considered to be produced by standing wave or resonant modes of the cavity which is radiating. 

Note that this is a classical thermodynamic model of how one could address radiation mathematically, without entering into the quantum mechanical details of  real life . When experiments were carried out it was found that the distribution predicted by classical electrodynamics had to be modified to avoid the ultraviolet catastrophy.:

But the predicted continual increase in radiated energy with frequency (dubbed the "ultraviolet catastrophe") did not happen. Nature knew better. 


Radiation is a wave in classical electrodynamics, its energy computable etc. The Planck black body formula addresses the dual nature of photons and waves of electromagnetism. Actually it is one of the basic early proofs that quantum mechanics was necessary to understand nature. The formula is fine and works fine with the rest of classical thermodynamics.
When it comes to solids, thermodynamics ignores the quantum discreteness of solids. It uses the black body radiation formula and it was found that  introducing the concept of "emissivity"  the energy output of a hot body was like the cavity radiation: A hot solid is modeled to the  a cavity model by taking the Stephan Boltzamn law and multiplying it by the emissivity to take care of the existence of the solid. This works fine for thermodynamic calculations.
When one wants to go to the real workings of the quantum mechanical energy balances within a solid  life becomes complicated, so much so that the quote 

The great complexity of dealing with all the quantum mechanisms and processes in a solid is the kind of thing that might have led Einstein to his purported preference for approaching problems from a thermodynamic perspective whenever possible.

To get to this concluding quote go to the stefan boltzman law , at the second paragraph there is a link "Why is a good absorber of radiation also a good emitter?" . It has an attempt at analyzing the solid state status quantum mechanically  for this and you can get an idea of the complexity. 
