Totally depends on how you access your e-mail.
You mention both yahoo and gmail in your post. If you go to a website and log-in to access your e-mail, you have them re-direct it so that it doesn't end up in your inbox.How to YahooHow to GMail.
If you use an e-mail client such as Outlook, Outlook Express, etc, you can setup filters and rules within that client.
There are also third party tools.
Really need a few more specifics.