The Ravens will receive a sixth-round draft choice in return, the sources said.
Boldin, who is in Africa on a mission, needs to pass a physical before the trade with San Francisco becomes complete.
The trade agreement was earlier reported by the Baltimore Sun.
Ravens receiver Torrey Smith took news of the trade hard, venting through his Twitter account.
"This business is BS at times," he wrote.
While Smith was upset, Boldin's potential new quarterback, Colin Kaepernick, was excited by the trade when he spoke with ESPN.
"If it's true, it's a great trade," Kaepernick told ESPN. "We're happy to have him. Having a playmaker like that at receiver is something you always want. It's another weapon for our offense and our team."
Kaepernick added that he thought the Niners were getting Boldin at a great value.
"He's a great player," Kaepernick said. "I don't think you're going to find anybody in the sixth round to come in and play better than what he's doing right now."
The Ravens had reportedly asked Boldin to take a pay cut to help the team with its salary-cap situation. Boldin is scheduled to earn $6 million in the coming season. He carries a $7.531 million salary-cap figure.
Boldin told USA Today on Saturday that he was unwilling to slash his salary in order to stay with the team, citing "principles."
"At no point, no matter how well I played, would I come back to the table and say, 'I need more money.' The contract that I signed was the contract that I intended to play out," he told USA Today.
In the playoffs, Boldin caught 22 passes for 380 yards receiving (95 yards per game) and four touchdowns. He has led Baltimore in receiving yards in each of the past three seasons since being traded from Arizona.
ESPN NFL Insider Adam Schefter and ESPN.com senior writer John Clayton contributed to this report.