The E1 strength function for 15 stable and unstable Sn even-even isotopes from A = 100 to A = 176 are calculated using a self-consistent microscopic theory which, in addition to the standard (quasiparticle) randomphase approximation [(Q)RPA] approach, takes into account phonon coupling and the single-particle continuum (by means of the discretization procedure) with a cutoff of 100 MeV. Our analysis shows two distinct regions for which the integral characteristics of both the giant and pygmy resonances behave rather differently. For neutron-rich nuclei, starting from 132 Sn, we obtain a giant E1 resonance which significantly deviates from the widely used systematics extrapolated from experimental data in the β-stability valley. We show that the inclusion of phonon coupling is necessary for a proper description of the low-energy pygmy resonances and the corresponding transition densities for A < 132 nuclei, while in the A > 132 region the influence of phonon coupling is significantly smaller. The radiative neutron capture cross sections leading to the stable 124 Sn and unstable 132 Sn and 150 Sn nuclei are calculated with both the (Q)RPA and the beyond-(Q)RPA strength functions and shown to be sensitive to both the predicted low-lying strength and the phonon-coupling contribution. The comparison with the widely used phenomenological generalized Lorentzian approach shows considerable differences both for the strength function and the radiative neutron capture cross section. In particular, for the neutron-rich 150 Sn, the reaction cross section is found to be increased by a factor greater than 20. We conclude that the present approach may provide a complete and coherent description of the γ -ray-strength function for astrophysics applications. In particular, such calculations are highly recommended for a reliable estimate of the electromagnetic properties of exotic nuclei.