The 49ers have agreed to terms with Anquan Boldin on a two-year contract, lasting through the 2015 season.