Secure sc_send_mail with MS 365 not working

Hi,

I’m trying to use sc_send_mail with MS 365 so I’ve these settings:

$smtp_server = ‘smtp.office365.com’;
$user = ‘xxxxx@xxxxxx.xxx’;
$pwd = ‘xxxxxx’;
$from = ‘xxxxx@xxxxxx.xxx’;
$to = ‘xxxxx@xxxxxx.xxx’;
$subject = ‘test’;
$message = ‘test’;
$msg_type = ‘H’;
$copy_recipients = ‘’;
$copy_type = ‘’;
$port = ‘587’;
$conn_type = ‘S’;
$attach = ‘’;
$ssl = ‘’;

sc_mail_send($smtp_server, $user, $pwd, $from, $to, $subject, $message, $msg_type, $copy_recipients, $copy_type, $port, $conn_type, $attach, $ssl);

The result I get is this:

stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Changing to TSL:

$conn_type = ‘T’;

I get this error

Fatal error : Uncaught Swift_TransportException: Unable to connect with TLS encryption in /opt/NetMake/v9-php73/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/EsmtpTransport.php:315 Stack trace: #0 /opt/NetMake/v9-php73/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/AbstractSmtpTransport.php(118): Swift_Transport_EsmtpTransport->_doHeloCommand() #1 /opt/NetMake/v9-php73/wwwroot/scriptcase/prod/third/swift/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #2 /opt/NetMake/v9-php73/wwwroot/scriptcase/app/procrm/control_test/control_test_apl.php(1810): Swift_Mailer->send(Object(Swift_Message), Array) #3 /opt/NetMake/v9-php73/wwwroot/scriptcase/app/procrm/control_test/control_test_apl.php(1054): control_test_apl->sc_btn_test_email() #4 /opt/NetMake/v9-php73/wwwroot/scriptcase/app/procrm/control_test/control_test_apl.php(1083): control_test_apl->ini_controle() #5 /opt/NetMake/v9-php73/wwwroot/scriptcase/app/procrm/control_test/index.php(1872): control_test_apl->controle() #6 { in /opt/NetMake/v9-php73/wwwroot/scriptcase/prod/third/swift/classes/Swift/Transport/EsmtpTransport.php on line 315

Is anyone successfully using sc_send_mail with MS 365 with secure authentication?
(I know it works with plain unsecure SMTP on port 25)

Did you find any resolution on this one?

Hi Daniel
Nope. If no one have any solution I guess I’ll have to find a php library capable of using tls with 365.

I have been using O365 as the smtp mailer for some time. My settings are in the API are:
Mode: Project
Gateway: SMTP
SMTP Server: smtp.office365.com
SMTP Port: 587
SMTP Prototcol: TLS

But when using the simple email macro is $mail_tp_connection = ‘T’;

So sorry to say its pretty much the same as you have.

Regards
Doug

I also just found at the bottom of the help section for the sc_mail_send macro
Note: To use safe connection its required to have the PHP "php_openssl " extension enable.

It must be this or something similar as I’ve found out the issue is only in the dev environment and I’ve no problem with TLS in production.

Any idea on how to add\load php_openssl in the sc provided apache\php on linux?

Sorry, can’t help. I use Scriptcase Host and its an easy cPanel selection.

Did you solve the problem?

Haven’t tried again since then.
In the meantime I upgraded SC to PHP8, but I have yet to check if that makes any difference.

I might be trying this with 365 too. To enable the php extension you should try this: https://serverfault.com/questions/162599/how-to-install-php-openssl-dll