A machine for packaging mattresses, comprising at least two functional layers (110, 120, 150), the packaging machine comprising: first movement means configured to move a mattress being processed along a first movement path and according to a first feed direction, the mattress being processed comprising one or more functional layers, means for applying adhesive material positioned along the first movement path and configured to distribute adhesive material on a surface of the mattress being processed which is positioned along the first movement path, second movement means configured to move a functional layer to be applied to the mattress being processed along a second movement path and according to a second feed direction, the second movement path being located preferably at least partly above the first movement path and converging with the first movement path at a placement station wherein the functional layer is placed on the mattress being processed, detection means configured and programmed to detect the position and the sizes of the mattress being processed and of the functional layer, a control unit operatively connected at least to the first movement means, to the second movement means and to the detection means, and programmed to: - receive a detection signal from the detection means indicating the position and the sizes of the mattress being processed and of the functional layer, characterized in that said control unit is further programmed to: - generate a control signal of the first and second movement means (2, 8) to change the position of the mattress being processed and of the functional layer as a function of the detection signal so as to cause the position of the mattress being processed to coincide with the functional layer along the relative movement path at the placement station. first movement means configured to move a mattress being processed along a first movement path and according to a first feed direction, the mattress being processed comprising one or more functional layers, means for applying adhesive material positioned along the first movement path and configured to distribute adhesive material on a surface of the mattress being processed which is positioned along the first movement path, second movement means configured to move a functional layer to be applied to the mattress being processed along a second movement path and according to a second feed direction, the second movement path being located preferably at least partly above the first movement path and converging with the first movement path at a placement station wherein the functional layer is placed on the mattress being processed, detection means configured and programmed to detect the position and the sizes of the mattress being processed and of the functional layer, a control unit operatively connected at least to the first movement means, to the second movement means and to the detection means, and programmed to: - receive a detection signal from the detection means indicating the position and the sizes of the mattress being processed and of the functional layer, characterized in that said control unit is further programmed to: - generate a control signal of the first and second movement means (2, 8) to change the position of the mattress being processed and of the functional layer as a function of the detection signal so as to cause the position of the mattress being processed to coincide with the functional layer along the relative movement path at the placement station. - receive a detection signal from the detection means indicating the position and the sizes of the mattress being processed and of the functional layer, characterized in that said control unit is further programmed to: - generate a control signal of the first and second movement means (2, 8) to change the position of the mattress being processed and of the functional layer as a function of the detection signal so as to cause the position of the mattress being processed to coincide with the functional layer along the relative movement path at the placement station.