I am writing a program for Android using Delphi to send an email with data. As is, my app is having connectivity issues.
I have
set the host to smtp.gmail.com,
put in my username and password for my gmail account,
put valid information in for the address and body fields of a TIdMessage,
made and added an attachment file,
set the SSL Options for a TIdSSLIOHandlerSocketOpenSSL according to the online examples, and
added all of the SASL Mechanisms Indy offers.
I am using port 587 and have connected to TLS explicitly.
type
TForm1 = class(TForm)
SendBtn: TButton;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
IdSASLAnonymous1: TIdSASLAnonymous;
IdSASLCRAMMD51: TIdSASLCRAMMD5;
IdSASLCRAMSHA11: TIdSASLCRAMSHA1;
IdSASLDigest1: TIdSASLDigest;
IdSASLExternal1: TIdSASLExternal;
IdSASLLogin1: TIdSASLLogin;
IdSASLOTP1: TIdSASLOTP;
IdSASLOTP2: TIdSASLOTP;
IdSASLPlain1: TIdSASLPlain;
IdSASLSKey1: TIdSASLSKey;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
procedure SendBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Attachment : TIdAttachmentFile;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
IdSMTP1.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(idSMTP1);
IdSMTP1.UseTLS := utUseExplicitTLS;
IdSMTP1.AuthType := satSASL;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLCRAMSHA11;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLAnonymous1;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLCRAMMD51;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLDigest1;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLExternal1;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLLogin1;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLOTP1;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLOTP2;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLPlain1;
IdSMTP1.SASLMechanisms.Add.SASL := IdSASLSKey1;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvTLSv1;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode := sslmUnassigned;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyMode := [];
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyDepth := 0;
end;
procedure TForm1.SendBtnClick(Sender: TObject);
begin
if IdSMTP1.Connected=True then IdSMTP1.Disconnect;
IdMessage1.From.Address := '[email protected]';
IdMessage1.Recipients.EMailAddresses := '[email protected]';
IdMessage1.BccList.Add.Address := '';
IdMessage1.CCList.Add.Address := '';
IdMessage1.Priority := mpHigh;
IdMessage1.Sender.Address := '[email protected]';
IdMessage1.Subject := 'Test Data'; //Add Date/time
IdMessage1.Body.Add('Hello!');
Attachment := TIdAttachmentFile.Create(IdMessage1.MessageParts, (GethomePath+'/Test.txt'));
IdSMTP1.Connect;
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect;
end;
Fails at:
IdSMTP1.Connect;
Is there a know problem with connecting to Android in this manner?