How to connect to ports 25 and 587

Your VPS host might have a firewall upstream from your server and independent of your server and it might be the one blocking your connection from 25 and 587. Could you check your VPS service provider’s control panel to check if they have their own firewall in place and if you can configure it to open 25 and 587?

I can confirm that Virtualmin does not block 25 and 587 by default, so you need not do anything to open those ports - they are open by default.

edit; Joe just said the same thing in a much better way.