Olá a todos,
Não estou a conseguir enviar emails em ambiente de produção, mas funciona no ambiente de desenvolvimento. Penso que tenha a ver com a configuração de PHP para SSL.
Estou a usar a API, com os dados seguintes:
CONFIGURAÇÃO API SENDMAIL
Nome: ApiSendMail
Modo: Público
Gateway : smtp
Servidor SMTP: smtp.meudominio.pt
Porta SMTP: 465
Usuário SMTP: site.admin@meudominio.pt
Senha SMTP: minhasenha
Protocolo SMTP: SSL
Do email: site.admin@meudominio.pt
Do nome: Site Admin
Este é o código para envio de email:
$var_config = array(
‘profile’ => ‘ApiSendMail’,
'message' => [
'html' => '<p>test</p>',
'text' => '',
'to' => 'endereco@gmail.com',
'subject' => 'teste'
]
);
sc_send_mail_api($var_config);
Obtenho o seguinte erro em ambiente de produção:
ERRO
stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
ERRO
stream_socket_client(): Failed to enable crypto
ERRO
stream_socket_client(): unable to connect to ssl://smtp.cercipeniche.pt:465 (Unknown error)
Fatal error: Uncaught Swift_TransportException: Connection could not be established with host smtp.cercipeniche.pt [ #0] in C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod\third\swift\classes\Swift\Transport\StreamBuffer.php:269 Stack trace: #0 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod\third\swift\classes\Swift\Transport\StreamBuffer.php(62): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod\third\swift\classes\Swift\Transport\AbstractSmtpTransport.php(113): Swift_Transport_StreamBuffer->initialize(Array) #2 C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod\third\swift\classes\Swift\Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #3 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\Informa3_lib\lib\php\nm_api.php(619): Swift_Mailer->send(Object(Swift_Message)) #4 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\Informa3\send_mail_test\index.php(1606): sc_send_mail_api(Array) #5 C:\Program Files\NetMake\v9\wwwroot\scriptcase\ in C:\Program Files\NetMake\v9\wwwroot\scriptcase\prod\third\swift\classes\Swift\Transport\StreamBuffer.php on line 269
Obrigado pela ajuda desde já,
João Gomes