In this paper we introduce the notion of $\lambda$-constacyclic codes over finite rings $R$ for arbitary element $\lambda$ of $R$. We study the non-invertible-element constacyclic codes (NIE-constacyclic codes) over finite principal ideal rings (PIRs). We determine the algebraic structures of all NIE-constacyclic codes over finite chain rings, give the unique form of the sets of the defining polynomials and obtain their minimum Hamming distances. A general form of the duals of NIE-constacyclic codes over finite chain rings is also provided. In particular, we give a necessary and sufficient condition for the dual of an NIE-constacyclic code to be an NIE-constacyclic code. Using the Chinese Remainder Theorem, we study the NIE-constacyclic codes over finite PIRs. Furthermore, we construct some optimal NIE-constacyclic codes over finite PIRs in the sense that they achieve the maximum possible minimum Hamming distances for some given lengths and cardinalities.