Permissions

I am looking at how to secure my application. One of the things I do not know yet is about the required permissions.

What are the most secure permission to be set on files and directories for the advanced template?

I seem to have a problem with permissions and swiftmailer component

and when I set EVERYTHING to 777 I get Error 500 - Internal Server Error