Getting around emails landing on spam box

Thinking on doing mass emailing using self-hosted email, but the thing is that most of them are gmails and yahoos, and I've done it couple of times and it always landed on spam box.

Would love to know some software that will do the trick to land it on their main box. Thanks!