Alpha channel through glass material instead of background (Cycles)
By mixing a glass or glossy shader with a transparent shader based on a fresnel node, rays will be allowed straight through the glass at smaller angles of incidence, and will reflect at grazing angles. Rays which go through and reach the environment background will give alpha transparency:



Note that the Fresnel node is not necessary for mixing (setting the factor directly will get something like what you are looking for), but it does make the reflections of the material behave in a more physically based manner.