Everything is disabled on your server would also allow you to connect to other server if you have internet connectivity allowed on that server and you are allowed outgoing connections on smtp server port.

I am not sure why you would like to have such script when SMTP server can get all done.