Ian Branch 128 Posted August 29, 2022 Hi Team, A Customer has asked about sending SMS messages from their Delphi App. I found the following code by Remy. var lHTTP: TIdHTTP; lParamList: TStringList; lResult: String; IdSSL : TIdSSLIOHandlerSocketOpenSSL; begin lParamList := TStringList.Create; try lParamList.Add('user=****'); lParamList.Add('password=****' ); lParamList.Add('message=Hello World'); lParamList.Add('sender=TestAccount'); lParamList.Add('mobile=+9195....'); lParamList.Add('type=1'); // or 3 lHTTP := TIdHTTP.Create(nil); try // note: if you are using an up-to-date version of Indy, // assigning the IOHandler is optional: // // http://www.indyproject.org/sockets/blogs/ChangeLog/20141222.aspx // lHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP); try lResult := lHTTP.Post('https://www.bulksmsgateway.in/sendmessage.php', lParamList); // WriteLn(lResult); // Readln; except on E: Exception do begin //WriteLn('Error: ', e.Message); end; end; finally FreeAndNil(lHTTP); end; finally FreeAndNil(lParamList); end; end; Is it still valid? Regards & TIA, Ian Share this post Link to post
Angus Robertson 577 Posted August 29, 2022 No idea about that Indian company, but there are lots of similar companies offering SMS HTTP APIs, at varying prices and levels of reliability in delivery, I use https://thesmsworks.co.uk/developers (which is also supported by ICS). You'd have to adjust the parameters slightly. Angus Share this post Link to post
Ian Branch 128 Posted August 29, 2022 Something in the Pacific region would be nice.. Share this post Link to post
Ian Branch 128 Posted August 29, 2022 I have had a modicum of success with the above code. It at least runs. 😉 I am getting the error.. "Error connecting with SSL". 😞 I have the latest ssleay & libeay dll files in the directory. Share this post Link to post
Remy Lebeau 1436 Posted August 29, 2022 (edited) 7 hours ago, Ian Branch said: I am getting the error.. "Error connecting with SSL". 😞 Does the server require TLS 1.1+, by chance? By default, TIdSSLIOHandlerSocketOpenSSL enables only TLS 1.0 (issue #181). Have you tried enabling TLS 1.1 and/or TLS 1.2 in the TIdSSLIOHandlerSocketOpenSSL.SSLOptions.SSLVersions property? Quote I have the latest ssleay & libeay dll files in the directory. Define "latest". TIdSSLIOHandlerSocketOpenSSL requires OpenSSL 1.0.2 or earlier, it does not support OpenSSL 1.1+. For that, you need to use this SSLIOHandler instead. Edited August 29, 2022 by Remy Lebeau Share this post Link to post
Ian Branch 128 Posted August 29, 2022 Hi Remy, Thank you. I should have mentioned D11.1.1 with the GetIt Indy. I am using the v 1.0.2u libraries. I cannot see how/where to set the 'SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2];'.. To me the logical place would be into IdSSL i.e. 'IdSSL.SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2];', however it doesn't appear to be being used anywhere. Regards, Ian Share this post Link to post
Remy Lebeau 1436 Posted August 29, 2022 (edited) 1 hour ago, Ian Branch said: I cannot see how/where to set the 'SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2];'.. To me the logical place would be into IdSSL i.e. 'IdSSL.SSLOptions.SSLVersions := [sslvTLSv1_1, sslvTLSv1_2];', however it doesn't appear to be being used anywhere. That is because your code is not using the IdSSL variable for anything. You are creating the TIdSSLIOHandlerSocketOpenSSL instance and assigning it directly to the TIdHTTP.IOHandler property, thus leaving all of the IOHandler's sub-properties at their default values. Assign the instance to the IdSSL variable first, and then you can customize its properties as needed, eg: lHTTP := TIdHTTP.Create(nil); try IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP); IdSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]; // set other properties as needed... lHTTP.IOHandler := IdSSL; ... finally lHTTP.Free; end; Edited August 29, 2022 by Remy Lebeau Share this post Link to post
Ian Branch 128 Posted August 29, 2022 Ahhh Ha! Thanks Remy. I figured it had to be something like that but I don't know enough about Indy and this type of thing.. :-( All good now. Appreciated. Regards, Ian Share this post Link to post