Hello,
I'm not add any files to my project, I need the openssl library I think to start this program properly.
I use LaztoApk version 0.9.026
SDK version 23.0.2
The Lazarus version is 1.3 with FPC 2.7.1
My target device will be a tablet but now i test it on my Dell Steak 5(rooted bootloader open)
I post the source code(btw it's working perfectly on windows):
unit Testmain;
{$mode objfpc}{$H+}
{$ifdef Linux}{$ifdef CPUARM}
{$define Android}
{$endif}{$endif}
interface
uses
Classes,
SysUtils,
FileUtil,
Forms,
Controls,
Graphics,
Dialogs,
StdCtrls,
ExtCtrls,
StrUtils,
customdrawnint,
LCLIntf,
customdrawncontrols,
customdrawndrawers,
customdrawn_common,
lazdeviceapis,
IdSMTP,
IdSSLOpenSSL,
IdMessage,
dynlibs;
type
{ TfrmTestMain }
TfrmTestMain = class(TForm)
CDButton1: TCDButton;
CDButton2: TCDButton;
CDButton3: TCDButton;
CDinf: TCDStaticText;
Msg: TIdMessage;
SSL: TIdSSLIOHandlerSocketOpenSSL;
SMTP: TIdSMTP;
procedure CDButton1Click(Sender: TObject);
procedure CDButton2Click(Sender: TObject);
procedure CDButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
frmTestMain: TfrmTestMain;
implementation
{$R *.lfm}
{ TfrmTestMain }
procedure TfrmTestMain.CDButton3Click(Sender: TObject);
begin
Close;
end;
//this part was for only test but not worked(cause Android is not Windows)
//procedure TfrmTestMain.FormCreate(Sender: TObject);
//var
// L1Handle, L2Handle: TLibHandle;
//begin
// L1Handle := LoadLibrary('libeay32.dll');
// L2Handle := LoadLibrary('ssleay32.dll');
//end;
//this part was for only test but not worked(cause Android is not Windows)
procedure TfrmTestMain.CDButton1Click(Sender: TObject);
begin
SMTP.Username:= 'smtpteszt2014@gmail.com';
SMTP.Password:= '*********';
SMTP.Host:= 'smtp.gmail.com';
SMTP.Port:= 587;
SSL.Destination:= 'smtp.gmail.com:587';
if(not SMTP.Connected)then
begin
CDinf.Caption:= 'Csatlakozva a(z) smtp.gmail.com kiszolgálóhoz.';
CDButton1.Caption:= 'Disconnect';
SMTP.Connect;
SMTP.Authenticate;
end else
begin
SMTP.Disconnect;
CDinf.Caption := 'Sikeres lecsatlakozás.';
CDButton1.Caption := 'Connect';
end;
end;
procedure TfrmTestMain.CDButton2Click(Sender: TObject);
var
mydate: string;
begin
Msg.CharSet:= 'utf-8';
Msg.From.Name:= UTF8Encode('Sp0T');
Msg.From.Address:= 'smtpteszt2014@gmail.com';
Msg.ReplyTo.EMailAddresses:= 'smtpteszt2014@gmail.com';
Msg.Recipients.EMailAddresses:= mymail@gmail.com';
mydate := FormatDateTime('yyyy.mm',Now);
Msg.Subject:= UTF8Encode('Android Test Mail');
Msg.Body.Text:=UTF8Encode('Hello'+#13#10+#13#10+
'I am a test android program.'+#13#10+
'Please do not replay to me');
Msg.Date := Sysutils.Date;
Msg.MessageParts.Clear;
SMTP.Send(Msg);
end;
end.