The matrix equation Sigma(u)(l=1) A(i)XB(i) + Sigma(v)(s=1) (CsXDs)-D-T = F, which includes some frequently investigated matrix equations as its special cases, plays important roles in the system theory. In this paper, we propose an iterative algorithm for solving the quaternion matrix equation Sigma(u)(l=1) A(i)XB(i) + Sigma(v)(s=1) (CsXDs)-D-T = F over generalized (P, Q)-reflexivematrices. The proposed iterative algorithmautomatically determines the solvability of the quaternion matrix equation over generalized (P, Q)-reflexive matrices. When the matrix equation is consistent over generalized (P, Q)-reflexive matrices, the sequence {X(k)} generated by the introduced algorithm converges to a generalized (P, Q)-reflexive solution of the quaternion matrix equation. And the sequence {X(k)} converges to the least Frobenius normgeneralized (P, Q)-reflexive solution of the quaternionmatrix equation when an appropriate initial iterativematrix is chosen. Furthermore, the optimal approximate generalized (P, Q)-reflexive solution for a given generalized (P, Q)-reflexive matrix X-0 can be derived. The numerical results indicate that the iterative algorithm is quite efficient.