SAN FRANCISCO — The drugs purchased from Safescripts Online were government-approved medications, the prescriptions signed by a licensed physician. And the world of Internet pharmacies was a virtual Wild West — no federal law applied.

For those reasons, three men charged with illegally distributing drugs through an online pharmacy believed their business passed legal muster, defense lawyers plan to tell a federal jury Monday in opening statements.