I went in July with only 4 months left on my passport. I couldn't do the immigration form online, but I was able to fill it out on the plane just like always and go through customs with no problem. Check the Mexican State Department website to make sure it hasn't changed, but as of July, your passport only had to valid through the end of your planned stay (as long as you have a flight home booked!)