My advice: avoid Massachusetts like the plague. It sucks (not that I would live in Maine either).
NH is where it's at!
I have lived in Mass my whole life and I disagree about avoiding it. I have also worked in NH for 30 years -- there are decent places there and you'll get a small town feel in a number of towns. But southern NH isn't necessarily cheap.
Some have suggested Billerica as less expensive small town (not Maine small town, but smallish) that is probably affordable and a decent location to mall towns -- 10 minutes from Burlington, 20 from Nashua; and on a good day only about 30 minutes from Boston.
I live in Chelmsford which borders Billerica, Lowell (nice restaurants and some night life -- a city), Carlisle and Westford. Chelmsford would be more expensive, generally, than Billerica, but very nice, safe, and good proximity to Nashua, Boston, Burlington, Lowell.