Using: Delphi XE7, latest daily build of Indy 10.
This code was working 2 months earlier. Now I recompiled my app, and its not working anymore, with the same account details. The exception message is 'Disconnected'.
The SMTP port used is 587.
Code follows:
FIdSMTP := TIdSMTP.Create;
FIdSSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create;
FIdMessage := TIdMessage.Create;
FIdAttachment := TIdAttachmentFile.Create(FIdMessage.MessageParts);
if (FEmailServer.SMTPUseSSL) then
begin
FIdSSLIOHandler.SSLOptions.Method := sslvTLSv1;
// FIdSSLIOHandler.SSLOptions.Method := sslvSSLv3;
FIdSMTP.IOHandler := FIdSSLIOHandler;
FIdSMTP.UseTLS := utUseExplicitTLS;
// FIdSMTP.UseTLS := utUseImplicitTLS;
end;
FIdSMTP.Host := FEmailServer.SMTPHost; //smtp.gmail.com
FIdSMTP.Port := FEmailServer.SMTPPort; //587
FIdSMTP.AuthType := satDefault;
FIdSMTP.Username := FEmailServer.SMTPUserName;
FIdSMTP.Password := FEmailServer.SMTPPassword;
FIdMessage.Recipients[0].Address := mailmessage.RecipientEmailAddr;
FIdMessage.From.Name := mailmessage.SenderName;
FIdMessage.Subject := mailmessage.EmailSubject;
FIdMessage.Body.Text := mailmessage.EmailMessage;
FIdAttachment.LoadFromFile(mailmessage.AttachmentFile);
FIdAttachment.FileName := ExtractFileName(mailmessage.AttachmentFile);
try
if (not FIdSMTP.Connected) then
FIdSMTP.Connect;
FIdSMTP.Send(FIdMessage);
except
on E: Exception do
ShowMessage(E.Message);
end;
Do you see anything obvious that could be causing it to not send the email?
Thank you, Remy! Beautiful tip! This code now works:
FIdSMTP := TIdSMTP.Create;
FIdSSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create;
FIdMessage := TIdMessage.Create;
FIdAttachment := TIdAttachmentFile.Create(FIdMessage.MessageParts);
FIdSASLCRAMSHA1 := TIdSASLCRAMSHA1.Create;
FIdSASLCRAMMD5 := TIdSASLCRAMMD5.Create;
FIdSASLDigest := TIdSASLDigest.Create;
FIdSASLSKey := TIdSASLSKey.Create;
FIdSASLOTP := TIdSASLOTP.Create;
FIdSASLAnonymous := TIdSASLAnonymous.Create;
FIdSASLExternal := TIdSASLExternal.Create;
FIdSASLLogin := TIdSASLLogin.Create;
FIdSASLPlain := TIdSASLPlain.Create;
if (FEmailServer.SMTPUseSSL) then
begin
FIdSSLIOHandler.SSLOptions.Method := sslvTLSv1;
// FIdSSLIOHandler.SSLOptions.Method := sslvSSLv3;
FIdSMTP.IOHandler := FIdSSLIOHandler;
FIdSMTP.UseTLS := utUseExplicitTLS;
// FIdSMTP.UseTLS := utUseImplicitTLS;
end;
FIdSMTP.Host := FEmailServer.SMTPHost; //smtp.gmail.com
FIdSMTP.Port := FEmailServer.SMTPPort; //587
FIdSMTP.AuthType := satSASL;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLCRAMSHA1;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLCRAMMD5;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLDigest;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLSKey;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLOTP;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLAnonymous;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLExternal;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLLogin;
FIdSMTP.SASLMechanisms.Add.SASL := FIdSASLPlain;
FIdSMTP.Username := FEmailServer.SMTPUserName;
FIdSMTP.Password := FEmailServer.SMTPPassword;
FIdMessage.Recipients[0].Address := mailmessage.RecipientEmailAddr;
FIdMessage.From.Name := mailmessage.SenderName;
FIdMessage.Subject := mailmessage.EmailSubject;
FIdMessage.Body.Text := mailmessage.EmailMessage;
FIdAttachment.LoadFromFile(mailmessage.AttachmentFile);
FIdAttachment.FileName := ExtractFileName(mailmessage.AttachmentFile);
try
if (not FIdSMTP.Connected) then
FIdSMTP.Connect;
FIdSMTP.Send(FIdMessage);
except
on E: Exception do
ShowMessage(E.Message);
end;
Freeing up the objects:
FIdAttachment.Free;
FIdMessage.Free;
FIdSSLIOHandler.Free;
FIdSMTP.Free;
FIdSASLCRAMSHA1.Free;
FIdSASLCRAMMD5.Free;
FIdSASLDigest.Free;
FIdSASLSKey.Free;;
FIdSASLOTP.Free;
FIdSASLAnonymous.Free;
FIdSASLExternal.Free;
FIdSASLLogin.Free;
FIdSASLPlain.Free;
..the USES list:
uses Classes, SysUtils, Windows, IdSMTP, IdMessage, IdSSLOpenSSL,
IdExplicitTLSClientServerBase, IdAttachmentFile, IdSASL,
IdSASLCollection, IdSASLAnonymous, IdSASLDigest, IdSASLExternal,
IdSASLLogin, IdSASLOTP, IdSASLPlain, IdSASLSKey, IdSASLUserPass,
IdSASL_CRAM_MD5, IdSASL_CRAM_SHA1;
Related
I tried to send mail using office365 smtp server but i am getting error "SSL Negotiation Failed". I have the latest openssl dll files. So the host in that case is smtp.office365.com.
I also tried a code sample from other post but with no success.
Can you help me please ?
procedure TForm7.Button3Click(Sender: TObject);
var
IdSMTPa: TIdSMTP;
IdMessage1: TIdMessage;
IdSSL: TIdSSLIOHandlerSocketOpenSSL;
begin
IdSMTPa := TIdSMTP.Create(nil);
try
IdSMTPa.Host := 'smtp.office365.com';
IdSMTPa.Port := 587;
IdSMTPa.Username := 'mymail#mydomain.gr';
IdSMTPa.Password := 'mypwd';
IdSMTPa.AuthType := satDefault;
// IO HANDLER Settings //
IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdSMTPa);
IdSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
IdSSL.SSLOptions.Mode := sslmUnassigned;
IdSSL.SSLOptions.VerifyMode := [];
IdSSL.SSLOptions.VerifyDepth := 0;
IdSMTPa.IOHandler := IdSSL;
IdSMTPa.UseTLS := utUseExplicitTLS;
IdMessage1 := TIdMessage.Create(nil);
try
IdMessage1.From.Address := 'mymail#mydomain.gr';
IdMessage1.Recipients.EMailAddresses := 'user1#mydomain.gr';
IdMessage1.CCList.EMailAddresses := 'user1#mydomain.gr';
IdMessage1.Subject := 'Test Email Subject';
IdMessage1.Body.Add('Test Email Body');
IdMessage1.Priority := mpHigh;
try
IdSMTPa.Connect();
try
IdSMTPa.Send(IdMessage1);
ShowMessage('Email sent');
finally
IdSMTPa.Disconnect();
end;
except
on e: Exception do
begin
ShowMessage('ERROR : '+e.Message);
end;
end;
finally
IdMessage1.Free;
end;
finally
IdSMTPa.Free;
end;
end;
I am trying to send an email with a PDF attachment, stored in a BLOB field, using TIdSMTP. For this I am using a TIdAttachmentMemory, but the code as shown results in 'refused by spam filter';
Omitting IdMessage.ContentType := 'multipart/mixed' works but the attachment is not sent (or received?) - as expected.
Leaving this statement and creating the attachment from a file (as in the commented code) it all works fine (i.e. mail correctly received with attachment).
Clearly I am missing something. I am suspecting something in the direction of the attachment not being "closed off" correctly (i.e. left in an incomplete state) or perhaps the incorrect ContentType?
All suggestions welcome. Thanks!
procedure TfrmSendMail.btnSendClick(Sender: TObject);
var
ms: TMemoryStream;
Attachment: TIdAttachmentMemory;
// Attachment: TIdAttachmentFile;
begin
memStatus.Clear;
IdSSLIOHandlerSocketOpenSSL.Destination := teHost.Text + ':587';
IdSSLIOHandlerSocketOpenSSL.Host := teHost.Text;
// IdSSLIOHandlerSocketOpenSSL.MaxLineAction := maException;
IdSSLIOHandlerSocketOpenSSL.Port := 587;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Method := sslvTLSv1_2;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode := sslmUnassigned;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.VerifyMode := [];
IdSSLIOHandlerSocketOpenSSL.SSLOptions.VerifyDepth := 0;
IdSMTP.Host := teHost.Text;
IdSMTP.Port := 587;
IdMessage.From.Address := teFrom.Text;
IdMessage.Recipients.EMailAddresses := teTo.Text;
IdMessage.Subject := teSubject.Text;
IdMessage.Body.Text := memBody.Text;
IdMessage.Body.Add('Timestamp: ' + FormatDateTime('yyyy-mm-dd hh:nn:ss', Now()));
IdMessage.ContentType := 'multipart/mixed';
if not sqlPDFPDF_Incasso.IsNull then
begin
ms := TMemoryStream.Create;
try
try
TBlobField(sqlPDF.FieldByName('PDF_Incasso')).SaveToStream(ms);
ms.Position := 0;
Attachment := TIdAttachmentMemory.Create(IdMessage.MessageParts, ms);
Attachment.ContentType := 'application/pdf';
Attachment.FileName := 'Invoice.pdf';
except
on E: Exception do
messageDlg('Error creating attachment' + #13#10 + E.Message, mtError, [mbOK], 0);
end;
finally
ms.Free;
end;
end;
// if FileExists(beAttachment.Text) then
// Attachment := TIdAttachmentFile.Create(IdMessage.MessageParts, beAttachment.Text);
Screen.Cursor := crHourGlass;
try
try
IdSMTP.Connect;
IdSMTP.Send(IdMessage);
memStatus.Lines.Insert(0, 'Email sent - OK.');
except
on E: Exception do
memStatus.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
finally
if assigned(Attachment) then
Attachment.Free;
if IdSMTP.Connected then
IdSMTP.Disconnect(true);
Screen.Cursor := crDefault;
end;
end;
You are not populating the TIdMessage correctly (see this blog article for details - your use-case would fall under the "HTML and non-related attachments and no plain-text" section, but replacing HTML with Plain-Text).
In a nutshell, if you include the attachment, setting the TIdMessage.ContentType to 'multipart/mixed' is fine, but you need to put the body text into a TIdText object in the TIdMessage.MessageParts instead of in the TIdMessage.Body. And if you don't include the attachment, using the TIdMessage.Body is fine, but you need to set the TIdMessage.ContentType to 'text/plain' instead.
Try this:
procedure TfrmSendMail.btnSendClick(Sender: TObject);
var
Text: TIdText;
Attachment: TIdAttachmentMemory;
Strm: TStream;
begin
memStatus.Clear;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Method := sslvTLSv1_2;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode := sslmClient;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.VerifyMode := [];
IdSSLIOHandlerSocketOpenSSL.SSLOptions.VerifyDepth := 0;
IdSMTP.Host := teHost.Text;
IdSMTP.Port := 587;
try
IdMessage.Clear;
IdMessage.From.Address := teFrom.Text;
IdMessage.Recipients.EMailAddresses := teTo.Text;
IdMessage.Subject := teSubject.Text;
//if FileExists(beAttachment.Text) then
if not sqlPDFPDF_Incasso.IsNull then
begin
IdMessage.ContentType := 'multipart/mixed';
Text := TIdText.Create(IdMessage.MessageParts, nil);
Text.Body.Text := memBody.Text;
Text.Body.Add('Timestamp: ' + FormatDateTime('yyyy-mm-dd hh:nn:ss', Now()));
Text.ContextType := 'text/plain';
//Attachment := TIdAttachmentFile.Create(IdMessage.MessageParts, beAttachment.Text);
Attachment := TIdAttachmentMemory.Create(IdMessage.MessageParts);
Attachment.ContentType := 'application/pdf';
Attachment.FileName := 'Invoice.pdf';
Strm := Attachment.PrepareTempStream;
try
TBlobField(sqlPDFPDF_Incasso).SaveToStream(Strm);
finally
Attachment.FinishTempStream;
end;
end else
begin
IdMessage.ContentType := 'text/plain';
IdMessage.Body.Text := memBody.Text;
IdMessage.Body.Add('Timestamp: ' + FormatDateTime('yyyy-mm-dd hh:nn:ss', Now()));
end;
Screen.Cursor := crHourGlass;
try
IdSMTP.Connect;
try
IdSMTP.Send(IdMessage);
finally
IdSMTP.Disconnect;
end;
memStatus.Lines.Insert(0, 'Email sent - OK.');
finally
Screen.Cursor := crDefault;
end;
except
on E: Exception do
memStatus.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
end;
Alternatively, Indy has a TIdMessageBuilderPlain class that can setup the TIdMessage properly for you (see this blog article for details - your use-case would fall under the "Plain-text and HTML and attachments: Non-related attachments only" section):
uses
..., IdMessageBuilder;
procedure TfrmSendMail.btnSendClick(Sender: TObject);
var
Strm: TStream;
Bldr: TIdMessageBuilderPlain;
begin
memStatus.Clear;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Method := sslvTLSv1_2;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode := sslmClient;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.VerifyMode := [];
IdSSLIOHandlerSocketOpenSSL.SSLOptions.VerifyDepth := 0;
IdSMTP.Host := teHost.Text;
IdSMTP.Port := 587;
try
IdMessage.Clear;
IdMessage.From.Address := teFrom.Text;
IdMessage.Recipients.EMailAddresses := teTo.Text;
IdMessage.Subject := teSubject.Text;
Strm := nil;
try
Bldr := TIdMessageBuilderPlain.Create;
try
Bldr.PlainText.Text := memBody.Text;
Bldr.PlainText.Add('Timestamp: ' + FormatDateTime('yyyy-mm-dd hh:nn:ss', Now()));
//if FileExists(beAttachment.Text) then
if not sqlPDFPDF_Incasso.IsNull then
begin
//Bldr.Attachments.Add(beAttachment.Text);
Strm := sqlPDFPDF_Incasso.DataSet.CreateBlobStream(sqlPDFPDF_Incasso, bmRead);
Bldr.Attachments.Add(Strm, 'application/pdf').WantedFileName := 'Invoice.pdf';
end;
Bldr.FillMessage(IdMessage);
finally
Bldr.Free;
end;
finally
Strm.Free;
end;
Screen.Cursor := crHourGlass;
try
IdSMTP.Connect;
try
IdSMTP.Send(IdMessage);
finally
IdSMTP.Disconnect;
end;
memStatus.Lines.Insert(0, 'Email sent - OK.');
finally
Screen.Cursor := crDefault;
end;
except
on E: Exception do
memStatus.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
end;
I migrated an IBX application which have 500+ forms to Firedac. I mapped the datatypes with Delphi Help. Here is my data mapping:
with ADB.FormatOptions do
begin
OwnMapRules := True;
DefaultParamDataType := ftVariant;
MapRules.Clear;
with MapRules.Add do
begin
PrecMax := 4;
PrecMin := 0;
ScaleMax := 0;
ScaleMin := 0;
SourceDataType := dtFmtBCD;
TargetDataType := dtInt16;
end;
with MapRules.Add do
begin
PrecMax := 10;
PrecMin := 5;
ScaleMax := 0;
ScaleMin := 0;
SourceDataType := dtFmtBCD;
TargetDataType := dtInt32;
end;
with MapRules.Add do
begin
PrecMax := 18;
PrecMin := 11;
ScaleMax := 0;
ScaleMin := 0;
SourceDataType := dtFmtBCD;
TargetDataType := dtInt64;
end;
with MapRules.Add do
begin
SourceDataType := dtFmtBCD;
TargetDataType := dtDouble;
end;
with MapRules.Add do
begin
SourceDataType := dtDateTimeStamp;
TargetDataType := dtDateTime;
end;
end;
Is this mapping is true? If it's false, how do I it's true?
When a FDQuery has parameters and a parameter has no value on execute the query,an exception occured :
[FireDAC][Phys][FB]-338. Param [XXX] type changed from [ftVariant] to [ftInteger]. Query must be reprepared. Possible reason: an assignment to a TFDParam.AsXXX property implicitly changed the parameter data type. Hint: use the TFDParam.Value or appropriate TFDParam.AsXXX property
How do I solve this problem? Thanks for everything.
I solved my problem by using the mapping below:
with ADB.FormatOptions do
begin
OwnMapRules := True;
with MapRules.Add do
begin
SourceDataType := dtDateTimeStamp;
TargetDataType := dtDateTime;
end;
with MapRules.Add do
begin
SourceDataType := dtDateTime;
TargetDataType := dtDateTimeStamp;
end;
end;
After than I build my application and test it. The Result is OK for me.
I am developing an email sending function in my iOS and Android apps.
It is a function to send an email via Gmail using OpenSSL.
I am using Delphi 10.2.3 Tokyo, with Indy 10.
I submitted my iOS app to iTunes Connect, but they rejected my app because this function does not work in IPv6.
They said
We discovered one or more bugs in your app when reviewed on iPad and iPhone running iOS 11.4.1 on Wi-Fi connected to an IPv6 network.
They also send me a screenshot of the error saying
An error occurred when resolving address smtp.gmail.com: (8)
How can I fix this error to work with IPv6 properly? My code is below:
Procedure MailSend;
Var
Connected: Boolean;
Begin
IdSMTP := TIdSMTP.Create(nil);
try
IdSMTP.Host := 'smtp.gmail.com';
IdSMTP.Port := 587;
IdSMTP.Username := 'xxxx#gmail.com'; // UserName
IdSMTP.Password := 'xxxx'; // Password
SSL := TIdSSLIOHandlerSocketOpenSSL.Create;
try
SSL.Host := IdSMTP.Host;
SSL.Port := IdSMTP.Port;
SSL.Destination := SSL.Host + ':' + IntToStr(SSL.Port);
IdSMTP.IOHandler := SSL;
IdSMTP.UseTLS := utUseExplicitTLS;
IdSMTP.Socket.IPVersion := Id_IPv6;
try
IdSMTP.Connect;
Connected := True;
except
Connected := False;
end;
If Connected = False then
Begin
IdSMTP.Socket.IPVersion := Id_IPv4;
IdSMTP.Connect;
End;
Msg := TIdMessage.Create(IdSMTP);
try
Msg.OnInitializeISO := IdMessage_InitializeISO;
Msg.ContentType := 'text/plain';
Msg.CharSet := 'UTF-8';
Msg.ContentTransferEncoding := 'BASE64'; // BASE64 (7bit)
//Msg.ContentTransferEncoding := '8bit'; // RAW(8bit)
Msg.From.Name := SsNoSt;
Msg.From.Address := 'xxxx#gmail.com';
Msg.Recipients.EMailAddresses := 'xxxx#gmail.com';
Msg.Subject := SsNoSt;
Msg.Body.Text := 'Unicode String (body)';
IdSMTP.Send(Msg);
finally
Msg.Free;
end;
IdSMTP.Disconnect;
finally
SSL.Free;
end;
finally
IdSMTP.Free;
End;
End;
I see a few problems with your SMTP code:
you need to set the IdSMTP.IPVersion property instead of the IdSMTP.Socket.IPVersion property. The default value of the IPVersion property is Id_IPv4 (bug - it is not respecting the ID_DEFAULT_IP_VERSION constant in the IdGlobal unit). Connect() overwrites the Socket.IPVersion property value with the IPVersion property value, so you are actually attempting to connect using Id_IPv4 twice, which will fail on an IPv6-only network (which Apple requires apps to support).
you are not catching any errors from the 2nd Connect(). That is likely the error that Apple is ultimately seeing.
you should not be setting the SSL.Host, SSL.Port, and SSL.Destination properties manually. Let Connect() handle that for you.
Try this instead:
// this accessor class is needed because TIdSMTP derives from TIdTCPClientCustom
// instead of TIdTCPClient. The IPVersion property is protected in
// TIdTCPClientCustom and not published by TIdSMTP or its ancestors.
//
// See https://github.com/IndySockets/Indy/issues/184 ...
//
type
TIdSMTPAccess = class(TIdSMTP)
end;
procedure MailSend;
var
IdSMTP: TIdSMTP;
Msg: TIdMessage;
begin
IdSMTP := TIdSMTP.Create(nil);
try
SSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdSMTP);
IdSMTP.IOHandler := SSL;
IdSMTP.Host := 'smtp.gmail.com';
IdSMTP.Port := 587;
IdSMTP.Username := 'xxxx#gmail.com';
IdSMTP.Password := 'xxxx';
IdSMTP.UseTLS := utUseExplicitTLS;
TIdSMTPAccess(IdSMTP).IPVersion := Id_IPv6;
try
IdSMTP.Connect;
except
TIdSMTPAccess(IdSMTP).IPVersion := Id_IPv4;
try
IdSMTP.Connect;
except
// unable to connect!
Exit;
end;
end;
try
Msg := TIdMessage.Create(nil);
try
Msg.OnInitializeISO := IdMessage_InitializeISO;
Msg.ContentType := 'text/plain';
Msg.CharSet := 'UTF-8';
Msg.ContentTransferEncoding := 'BASE64'; // BASE64 (7bit)
//Msg.ContentTransferEncoding := '8bit'; // RAW(8bit)
Msg.From.Name := SsNoSt;
Msg.From.Address := 'xxxx#gmail.com';
Msg.Recipients.EMailAddresses := 'xxxx#gmail.com';
Msg.Subject := SsNoSt;
Msg.Body.Text := 'Unicode String (body)';
IdSMTP.Send(Msg);
finally
Msg.Free;
end;
finally
IdSMTP.Disconnect;
end;
finally
IdSMTP.Free;
end;
end;
Alternatively:
type
TIdSMTPAccess = class(TIdSMTP)
end;
procedure MailSend;
var
IdSMTP: TIdSMTP;
Msg: TIdMessage;
Connected: Boolean;
begin
IdSMTP := TIdSMTP.Create(nil);
try
SSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdSMTP);
IdSMTP.IOHandler := SSL;
IdSMTP.Host := 'smtp.gmail.com';
IdSMTP.Port := 587;
IdSMTP.Username := 'xxxx#gmail.com';
IdSMTP.Password := 'xxxx';
IdSMTP.UseTLS := utUseExplicitTLS;
Connected := False;
if GStack.SupportsIPv6 then
begin
TIdSMTPAccess(IdSMTP).IPVersion := Id_IPv6;
try
IdSMTP.Connect;
Connected := True;
except
end;
end;
if (not Connected) and GStack.SupportsIPv4 then
begin
TIdSMTPAccess(IdSMTP).IPVersion := Id_IPv4;
try
IdSMTP.Connect;
Connected := True;
except
end;
end;
if not Connected then
begin
// unable to connect!
Exit;
end;
try
Msg := TIdMessage.Create(nil);
try
Msg.OnInitializeISO := IdMessage_InitializeISO;
Msg.ContentType := 'text/plain';
Msg.CharSet := 'UTF-8';
Msg.ContentTransferEncoding := 'BASE64'; // BASE64 (7bit)
//Msg.ContentTransferEncoding := '8bit'; // RAW(8bit)
Msg.From.Name := SsNoSt;
Msg.From.Address := 'xxxx#gmail.com';
Msg.Recipients.EMailAddresses := 'xxxx#gmail.com';
Msg.Subject := SsNoSt;
Msg.Body.Text := 'Unicode String (body)';
IdSMTP.Send(Msg);
finally
Msg.Free;
end;
finally
IdSMTP.Disconnect;
end;
finally
IdSMTP.Free;
end;
end;
IdMessage1.Clear;
IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlersocketopenSSL.Create(nil);
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvTLSv1;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode := sslmUnassigned;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyMode := [];
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyDepth := 0;
IdSSLIOHandlerSocketOpenSSL1.Host := 'smtp.gmail.com';
IdSSLIOHandlerSocketOpenSSL1.Port := 587;
IdSMTP1.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
IdSMTP1.UseTLS := utUseExplicitTLS;
IdMessage1.Body.Append('h');
IdMessage1.From.Name := '******';
IdMessage1.From.Address := '****';
IdMessage1.Recipients.EMailAddresses :='*****';
IdMessage1.Subject := 'POWIADOMIENIE';
IdSMTP1.UserName := '*******';
IdSMTP1.Password := '*******';
IdSMTP1.Host :='smtp.gmail.com';
IdSMTP1.Port := 587 ;
//IdSMTP1.AuthType := satDefault;
// IdSMTP1.Authenticate;
IdSMTP1.Connect;
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect;
//idSMTP1.Authenticate;
end;
Hello, trying to send email to gmail using INDY and Delphi XE7 . Unfortunately, I get the error
"SSL in not availaible on this server "
screen from Wireshark
Changing libeay32.dll and ssleay32.dll to the current Version solves the problem!