It is illegal for the USPS to look at the contents of first class mail except with a court order.
Other classes of mail may have less stringent protections. For instance, third class (and maybe second class, I forget) mail can be opened to make sure that the things it contains are allowed to be mailed in that class.
An x-ray is nothing like reading the contents of letters or randomly checking ahipped harddrives and USB sticks for content. I don't know how to clarify legally or conceptually, but I feel confident there is a very clear difference
I forgot about that. I think it's nearly all stamped mail over a certain weight? I don't remember if labeled mail is similarly scanned and my google skills are failing me today.
You'd be surprised about the amount of packages that gets x-rayed in order to find drugs. But yes, you're 100% right that it's not all of them.