Losses more than doubled at the US Postal Service in the first three months of the year to $1.3 billion. But that's not Amazon's fault.

President Donald Trump has frequently complained that Amazon (AMZN) takes advantage of the post office, which has a contract to help deliver many of the online shopping giant's packages. Last month he created a federal task force to look into the Postal Service's finances.

The Postal Service is a government agency, but it operates as an independent business without direct taxpayer support. It has lost $65 billion over the last 11 fiscal years.

The agency said Friday that it has been hurt by the ongoing decline in traditional mail, coupled with increased costs for retiree benefits. Revenue from first class mail and junk mail, which the Postal Service refers to as "marketing mail," fell by $181 million, or a 1.4%.

The Postal Service's package business, by contrast, is the one segment experiencing strong and steady growth. Its sales grew by $445 million,

Related: Trump orders Postal Service review after attacking Amazon

"I am right about Amazon costing the United States Post Office massive amounts of money for being their Delivery Boy. Amazon should pay these costs (plus) and not have them bourne by the American Taxpayer. Many billions of dollars. P.O. leaders don't have a clue (or do they?)!" he tweeted last month.

I am right about Amazon costing the United States Post Office massive amounts of money for being their Delivery Boy. Amazon should pay these costs (plus) and not have them bourne by the American Taxpayer. Many billions of dollars. P.O. leaders don't have a clue (or do they?)! — Donald J. Trump (@realDonaldTrump) April 3, 2018

Amazon has a confidential agreement with the Postal Service under which it delivers large numbers of packages directly to the post office nearest to where they need to be delivered. The Postal Service then delivers the packages the "last mile" to their destinations. The Postal Service says the law requires that such negotiated contracts cover its costs, and that regulators have studied the Amazon contract and approved it.

Related: Trump vs. Amazon - Let's set the record straight

Amazon also has a special agreement with the Postal Service to deliver packages on Sundays in limited major markets. Neither Amazon nor the post office have disclosed the details of that agreement, but the Postal Service says it's mutually beneficial.

This kind of confidential contract is not unusual for the Postal Service. Many large shippers negotiate them. They pay rates based on volume and what the post office has to do to make the deliveries.