If, when using the sc_mail_send macro in a Linux or MAC environment, the following error occurs:
Fatal error: Uncaught Swift_TransportException: Connection could not be established with host smtp.gmail.com [ #0] in /opt/Scriptcase/v9-php81/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/StreamBuffer.php:269 Stack trace: #0 /opt/Scriptcase/v9-php81/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/StreamBuffer.php(62): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /opt/Scriptcase/v9-php81/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/AbstractSmtpTransport.php(113): Swift_Transport_StreamBuffer->initialize(Array) #2 /opt/Scriptcase/v9-php81/wwwroot/scriptcase/prod/third/swift/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #3 /opt/Scriptcase/v9-php81/wwwroot/scriptcase/app/teste_mantis/blank/index.php(2425): Swift_Mailer->send(Object(Swift_Message), Array) #4 /opt/Scriptcase/v9-php81/wwwroot/scriptcase/app/teste_mantis/blank/index.php(2793): blank_apl->controle() #5 {main} thrown in /opt/Scriptcase/v9-php81/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/StreamBuffer.php on line 269
It will be necessary to follow the steps below to correct the error:
1º - Locate the php.ini file that is in the root directory:
- Linux : /opt/Scriptcase/v9-php81/components/php
- MAC : /Applications/Scriptcase/v9-php81/components/php/
2º - After locating the php.ini file, access it.
- Afterward, perform a search for lines 1932 and 1940 and insert the following values:
LINUX
in the line 1932 : curl.cainfo = "/opt/Scriptcase/v9-php81/components/php/etc/curl-ca-bundle.crt"
in the line 1940 : openssl.cafile="/opt/Scriptcase/v9-php81/components/php/etc/curl-ca-bundle.crt"
MAC
in the line 1932 : curl.cainfo = "/Applications/Scriptcase/v9-php81/components/php/etc/curl-ca-bundle.crt"
in the line 1940 : openssl.cafile = "/Applications/Scriptcase/v9-php81/components/php/etc/curl-ca-bundle.crt"
As shown in the image below
3º - After making changes to the php.ini file, save the changes and restart the Apache service for Scriptcase.
LINUX
/opt/Scriptcase/v9-php81/components/apache/sc_apache restart
Mac
/Applications/Scriptcase/v9-php81/components/apache/sc_apache restart
After restarting, attempt to send the email again in the application using the sc_send_mail macro. This time, the email will be sent without errors.