Context. The understanding of the formation process of massive stars ( > ∼ 8 M ) is limited by a combination of theoretical complications and observational challenges. The high UV luminosities of massive stars give rise to chemical complexity in their natal molecular clouds and affect the dynamical properties of their circumstellar envelopes. Aims. We investigate the physical structure of the large-scale (∼10 4 -10 5 AU) molecular envelope of the high-mass protostar AFGL2591. Methods. Observational constraints are provided by spectral imaging in the 330-373 GHz regime from the JCMT Spectral Legacy Survey and its high-frequency extension. While the majority of the ∼160 spectral features from the survey cube are spatially unresolved, this paper uses the 35 that are significantly extended in the spatial directions. For these features we present integrated intensity maps and velocity maps. The observed spatial distributions of a selection of six species are compared with radiative transfer models based on (i) a static spherically symmetric structure; (ii) a dynamic spherical structure; and (iii) a static flattened structure. Results. The maps of CO and its isotopic variations exhibit elongated geometries on scales of ∼100 , and smaller scale substructure is found in maps of N 2 H + , o-H 2 CO, CS, SO 2 , C 2 H, and various CH 3 OH lines. In addition, a line-of-sight velocity gradient is apparent in maps of all molecular lines presented here, except SO, SO 2 , and H 2 CO. We find two emission peaks in warm (E up ∼ 200 K) CH 3 OH separated by 12 (12 000 AU), indicative of a secondary heating source in the envelope. The spherical models are able to explain the distribution of emission for the optically thin H 13 CO + and C 34 S, but not for the optically thick HCN, HCO + , and CS or for the optically thin C 17 O. The introduction of velocity structure mitigates the optical depth effects, but does not fully explain the observations, especially in the spectral dimension. A static flattened envelope viewed at a small inclination angle does slightly better. Conclusions. Based on radiative transfer modeling, we conclude that a geometry of the envelope other than an isotropic static sphere is needed to circumvent line optical depth effects. We propose that this could be achieved in circumstellar envelope models with an outflow cavity and/or an inhomogeneous structure on scales 10 4 AU. The picture of inhomogeneity is supported by substructure observed in at least six different species.