[Solved] LAMW, problem of sending email using the Synapse library lazarus / 43-Android ---------------------------------------------------------------------- Alexin · 2020-04-20 19:21 Hello everyone! I am using IDE Laz4android 2.0.0 with LAMW. It is necessary to send a simple text Email from my Android application. To do this, I installed the Synapse libraries, using the SMTPSend, ssl_openssl modules (for encryption on port 465). But this does not work for me under Android, everything compiles and starts without errors, but the emails do not go away.  In the "libs \ armeabi-v7a" project folder, I put two ssl libraries “libcrypto.so" and "libssl.so” version 1.0.2j, tried other versions of these libraries, to no avail. In the SendToRaw function of the SMTPsend.pas module, I checked that FullSSL is enabled: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function SendToRaw(const MailFrom, MailTo, SMTPHost: string;  const MailData: TStrings; const Username, Password: string): Boolean;var  SMTP: TSMTPSend;  s, t: string;begin  Result := False;  SMTP := TSMTPSend.Create;  try// if you need SOCKS5 support, uncomment next lines:    // SMTP.Sock.SocksIP := '127.0.0.1';    // SMTP.Sock.SocksPort := '1080';// if you need support for upgrade session to TSL/SSL, uncomment next lines:     //SMTP.AutoTLS := True;// if you need support for TSL/SSL tunnel, uncomment next lines:     SMTP.FullSSL := True;    SMTP.TargetHost := Trim(SeparateLeft(SMTPHost, ':'));    s := Trim(SeparateRight(SMTPHost, ':'));    if (s <> '') and (s <> SMTPHost) then      SMTP.TargetPort := s;    SMTP.Username := Username;    SMTP.Password := Password;    if SMTP.Login then    begin      if SMTP.MailFrom(GetEmailAddr(MailFrom), Length(MailData.Text)) then      begin        s := MailTo;        repeat          t := GetEmailAddr(Trim(FetchEx(s, ',', '"')));        if t <> '' then            Result := SMTP.MailTo(t);          if not Result then            Break;        until s = '';        if Result then          Result := SMTP.MailData(MailData);      end;      SMTP.Logout;    end;  finally    SMTP.Free;  end;end;  The following is an excerpt from my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  Procedure SendMail (Host, Subject, pTo, From , TextBody, HTMLBody, login,password : string);var Msg : TMimeMess; // message    StringList : TStringList; // message content    MIMEPart : TMimePart; // parts of the message begin  Msg := TMimeMess.Create; // create new message  StringList := TStringList.Create;  try    // add headers    Msg.Header.Subject := Subject; // Message subject    Msg.Header.From := From; // name and address of sender    Msg.Header.ToList.Add(pTo); // recipient name and address    // create the root element    MIMEPart := Msg.AddPartMultipart('alternative', nil);    if length(TextBody)=0 then    // if format HTML      begin        StringList.Text := HTMLBody;        Msg.AddPartHTML(StringList, MIMEPart);      end    else    // if text format      begin        StringList.Text := TextBody;        Msg.AddPartText(StringList, MIMEPart);      end;    // encode and send    Msg.EncodeMessage;    // send    if smtpsend.SendToRaw(From,pTo,Host,Msg.Lines,login,password) then        ConnectForm.ShowMessage('Email Sent')    else        ConnectForm.ShowMessage('Email NOT Sent'); finally   Msg.Free;   StringList.Free; end;end;                                       procedure TConnectForm.jButton1Click(Sender: TObject);begin  SendMail('smtp.gmail.com:465',         'test email subject',         'recipient@gmail.com',         'sender@gmail.com’,       'The content of the letter in text format',         '',         'sender@gmail.com’, 'password')end;         Under Windows I checked, everything works fine (using the openssl, libeay32.dll and ssleay32.dll libraries). How to make it work under Android? Maybe someone faced such a problem?  In the folder with demos lazandroidmodulewizard, there were no examples of sending e-mail, there is only the jcMail component that can only receive e-mails, and not send. If anyone knows the solution, or shows a working example, I will be very grateful. ---------------------------------------------------------------------- yuriy_sydorov · 2020-04-21 11:31 Without exact error messages/codes and position where the error occurs it is not possible to help you. Also it is needed to specify the FPC version and the Android version. ---------------------------------------------------------------------- Alexin · 2020-05-02 19:01 Quote from: yuriy_sydorov on April 21, 2020, 01:31:22 pmWithout exact error messages/codes and position where the error occurs it is not possible to help you. Also it is needed to specify the FPC version and the Android version. Hello. Apparently, this happens when it tries to log in. SMTP.Login (From the function "SendToRaw" I cited above). This step failed. I tried to catch the error through LogCat ADB, but found nothing about this smtp connection. Although Synapse safely compiles for arm-android, I guess that it cannot access the web. Though, there is permission in AndroidManifest.xml:     FPC version 3.0.4 Target SDK Version: Android 9 (API Level 28) JDK: 1.8.0_241 Gradle 6.3 NDK: r10e LAMW: 0.8.5 OS: Windows 10 (x64) ---------------------------------------------------------------------- Seenkao · 2020-05-02 20:58 Use version FPC > 3.0.4 ---------------------------------------------------------------------- yuriy_sydorov · 2020-05-03 09:33 You need to use FPC 3.2 or FPC trunk. The netdb unit is unusable in FPC 3.0.2 for android. That's why synapse can't resolve host names and unable to connect. See known issues here: https://wiki.freepascal.org/Android#Known_issues ---------------------------------------------------------------------- Alexin · 2020-05-05 18:46 Quote from: yuriy_sydorov on May 03, 2020, 11:33:22 amYou need to use FPC 3.2 or FPC trunk. The netdb unit is unusable in FPC 3.0.2 for android. That's why synapse can't resolve host names and unable to connect. See known issues here: https://wiki.freepascal.org/Android#Known_issues I rebuild using FPC trunk and I got this error while compiling : custompage.inc:139:34: error: Operator is not overloaded: "Class Of TCustomTabControl" and "Boolean" Then I tried installing version FPC 3.2.0, and the program was compiled without errors, now sending emails works. Thank you so much, problem is solved.