To buy a gun online, it must be shipped to a licensed gun dealer, who then does a background check, and delivers your gun to you if/when you pass.
And of course guns can be shipped in the mail. How the heck do you think distributors get guns to individual dealers? Pony Express?
You can even have a gun in your checked baggage on a plane, so long as it's unloaded, in an approved case, and declared.