Cannot set up Outgoing Emails

Hello everyone!
I recently started using SuiteCRM-7.10.7. I installed it on a shared 1and1 (Italy) server. The PHP version is 7.2.
Unfortunately I came across a major obstacle: I cannot send test emails, nor can I send normal emails. Every time I try to send an email, the system enters a sort of loop and stops working for a few minutes.
I checked the suitecrm.log file and it throws the following errors:

Tue Aug 14 16:04:18 2018 [22770][1][FATAL] ERROR: rmdir_recursive(): argument cache/themes/SuiteP/modules is not a file or a dir.
Tue Aug 14 16:08:47 2018 [27679][1][FATAL] log call at: modules/EmailMan/tpls/config.tpl:444 - styleChecked is not set
Tue Aug 14 16:14:08 2018 [28867][1][FATAL] SugarPHPMailer encountered an error: An outgoing mail server is not configured to send emails. Please configure an outgoing mail server or select an outgoing mail server for the mail account that you are using in Settings >> Mail Account.
Tue Aug 14 16:14:08 2018 [28867][1][FATAL] SugarPHPMailer encountered an error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Tue Aug 14 16:14:08 2018 [28867][1][FATAL] SugarPHPMailer encountered an error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Tue Aug 14 16:14:08 2018 [30369][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [30369][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away
Tue Aug 14 16:14:08 2018 [30829][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [30829][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away
Tue Aug 14 16:14:08 2018 [31490][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [31490][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away
Tue Aug 14 16:14:08 2018 [32400][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [32400][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away
Tue Aug 14 16:14:08 2018 [33004][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [33004][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away
Tue Aug 14 16:14:08 2018 [33055][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [33055][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away
Tue Aug 14 16:14:08 2018 [33092][-none-][FATAL] Mysqli_query failed.
Tue Aug 14 16:14:08 2018 [33092][-none-][FATAL] Retrieving record by id users:1 found  Query Failed: SELECT users.* FROM users  WHERE users.id = '1' AND users.deleted=0 LIMIT 0,1: MySQL error 2006: MySQL server has gone away

The instructions provided by the 1and1 backend concerning SMTP details are pretty clear, nevertheless I tried all variations I could think of.
When I try to send a test email a message appears: “Performing Task: One moment please…” and I can only click “close” or a button “undefined”. After that I cannot use the system for a few minutes.
If I try to go to the homepage of the CRM while the system is not working, then the browser displays the following error:

Database failure. Please refer to suitecrm.log for details.
Fatal error: Uncaught Exception: Database failure. Please refer to suitecrm.log for details. in /homepages/12/d574299968/htdocs/crm.fst.eu/include/utils.php:1772 Stack trace: #0 /homepages/12/d574299968/htdocs/crm.fst.eu/include/database/DBManager.php(353): sugar_die('Database failur...') #1 /homepages/12/d574299968/htdocs/crm.fst.eu/include/database/DBManager.php(328): DBManager->registerError('Retrieving reco...', 'Retrieving reco...', true) #2 /homepages/12/d574299968/htdocs/crm.fst.eu/include/database/MysqliManager.php(177): DBManager->checkError('Retrieving reco...', true) #3 /homepages/12/d574299968/htdocs/crm.fst.eu/include/database/MysqlManager.php(285): MysqliManager->query('SELECT users.* ...', true, 'Retrieving reco...') #4 /homepages/12/d574299968/htdocs/crm.fst.eu/data/SugarBean.php(4545): MysqlManager->limitQuery('SELECT users.* ...', 0, 1, true, 'Retrieving reco...') #5 /homepages/12/d574299968/htdocs/crm.fst.eu/include/SugarObjects/templates/person/Person.php(113): SugarBean->retrieve('1', true, true) #6 / in /homepages/12/d574299968/htdocs/crm.fst.eu/include/utils.php on line 1772

I successfully tried to connect with the provided SMTP details via tools like https://pingability.com/smtptest.jsp and https://www.smtper.net/, however, according to the .log file the issue is that SMTP connect failed.

I also tried to save the settings and to send email via a case I opened. Also in those circumstances the system cannot be used for a few minutes.

Would you be able to help me understand how to fix this issue?
Thank you for your time.

Hi razdavid,

I’ve answered in the GitHub issue here: https://github.com/salesagility/SuiteCRM/issues/6245.