bzwirs 4 Posted June 14 Is it possible to use smtp on android to send multiple emails with attachments and are there any examples of this available. I don't want the email client popping up for each email .... just all done in the background. Thanks in advance. Bill Zwirs Share this post Link to post
Remy Lebeau 1419 Posted June 14 6 hours ago, bzwirs said: Is it possible to use smtp on android Sure. It's just a TCP connection to a server, like any other. Why would you think it's not possible? 6 hours ago, bzwirs said: are there any examples of this available. I don't want the email client popping up for each email .... just all done in the background. Indy 10 ships pre-installed with the IDE, and works on Android (mostly). It has TIdSMTP and TIdMessage components for sending emails. For TLS up to 1.2, there is TIdSSLIOHandlerSocketOpenSSL, and OpenSSL 1.0.2s libs for Android at https://github.com/IndySockets/OpenSSL-Binaries Or, you could simply use Android's built-in SSL/Socket class and implement the SMTP protocol yourself. Share this post Link to post
bzwirs 4 Posted June 22 On 6/15/2024 at 1:05 AM, Remy Lebeau said: Why would you think it's not possible? Several years ago I googled on the same issue and all I could find at the time was advise that it could not be done and needed to use Android Intents which called the mail client. This solution was Ok at the time as it would only be occasionally used in the app. But now I need to be able to send multiple emails so don't want the mail client popping up for each so asked the question in case things had changed. By the way, I am using Delphi 12 with latest updates. Since your reply I have been trying to use the Indy approach and found a post on Stackoverflow and followed the following advice: Add the 2 .so files to your project deployment and set them to deploy to the .\assets\internal\ folder add the System.StartupCopy unit as the first unit in your DPR's uses clause. call IdOpenSSLSetLibPath(TPath.GetDocumentsPath) at app startup. I am using the 64bit files included in openssl-1.0.2s_Android and keep getting the 'could not load SSL library' error. I have used FileExists to check if file (just for one of the files) is there. Here is the code I use in the OnFormCreate event. Compiled for Android64. Quote var aFile := TPath.Combine(TPath.GetDocumentsPath,'libssl.so'); IdOpenSSLSetLibPath(TPath.GetDocumentsPath); if FileExists(aFile) then IdSSLOpenSSLHeaders.Load(); Is there anything else I can try to make this work. Bill Zwirs Share this post Link to post
Remy Lebeau 1419 Posted June 22 (edited) 16 minutes ago, bzwirs said: I am using the 64bit files included in openssl-1.0.2s_Android and keep getting the 'could not load SSL library' error. What do Indy's IdSSLOpenSSLHeaders.WhichFailedToLoad() and IdSSLOpenSSL.OpenSSLVersion() functions report after the load fails? Edited June 22 by Remy Lebeau Share this post Link to post
DelphiUdIT 181 Posted June 23 22 hours ago, bzwirs said: Is there anything else I can try to make this work. I'm using to deploy the .so files in "library\lib\arm64-v8a\" and I don't have to do nothing at startup, no loads or other ... Try to put only: ShowMessage(OpenSSLVersion()); in a Form Create event and see if the version will show. Share this post Link to post
Remy Lebeau 1419 Posted June 23 22 minutes ago, DelphiUdIT said: Try to put only: ShowMessage(OpenSSLVersion()); in a Form Create event and see if the version will show. It is not just a matter of IF it shows, but also WHICH VERSION it shows. Anything above 1.0.2 is not going to work with the default TIdSSLIOHandlerSocketOpenSSL at this time. Share this post Link to post
DelphiUdIT 181 Posted June 23 7 minutes ago, Remy Lebeau said: It is not just a matter of IF it shows, but also WHICH VERSION it shows. Anything above 1.0.2 is not going to work with the default TIdSSLIOHandlerSocketOpenSSL at this time. He said to use 1.0.2s version. This means that the library should be that version. I only suggest to load on the default library path and see what happens. In the past time I have some issues with some versions of Android with .so libs loaded around the systems (in Shared Doc, External Doc, etc...). So I always loaded them in the default library paths. Share this post Link to post
bzwirs 4 Posted June 23 Remy and DelphiUdIT Have changed loading .so files to "library\lib\arm64-v8a\" and all appears to be working now. OpenSSLVersion now reports as "OpenSSL 1.0.2s-fips 28 May 2019". Previously I was just getting an empty string so maybe assume I was doing something wrong. Thanks for all your help. Bill Zwirs Share this post Link to post