Cops are not allowed to open your mail or go through your mail without a warrant, as the Fourth Amendment protects the mail's privacy.
Although exceptions to this do exist, which would be for exigent circumstances, like a dangerous package or if the mail is in the possession of a third party, such as a mail carrier that opens it.
Although the specific legal boundaries also can be complex.
Cops or police need a warrant to open sealed mail, and for a police officer to open and inspect your mail, they need a search warrant issued by a judge.
The warrant also must be based on probable cause, which means there's is a reason to believe evidence of a crime is inside the mail.