My Nextcloud wont sync to any email

I just installed Nextcloud for the first time on Linode and so far everything works but I can’t seem to be able to sync any email no matter if it’s gmail, custom or exchange. keep getting these types of errors. I don’t know if I missed something when installing Nextcloud, or if I didn’t set up a package on my server that I needed.

error message: A problem occurred while sending the email. Please revise your settings. (Error: Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out))

And on the log It shows this error:Error PHP Error: chmod(): Operation not permitted at /var/www/cloudserver/lib/private/Config.php#251