(01-07-2021, 01:36 PM)waikitlo Wrote: [ -> ]Hi, I am also trying to setup IdSMTP to send email. Could you share the settings of your setup?
Thanks.
Hello,
these are the components to put in Form:
object SMTP: TIdSMTP
IOHandler = IdSSLIOHandlerSMTP
Port = 465
SASLMechanisms = <>
UseTLS = utUseImplicitTLS
Left = 592
end
object IdSSLIOHandlerSMTP: TIdSSLIOHandlerSocketOpenSSL
Destination = ':465'
MaxLineAction = maException
Port = 465
DefaultPort = 0
SSLOptions.Method = sslvSSLv23
SSLOptions.SSLVersions = [sslvSSLv2, sslvSSLv3, sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]
SSLOptions.Mode = sslmUnassigned
SSLOptions.VerifyMode = []
SSLOptions.VerifyDepth = 0
Left = 592
Top = 96
end
object MailMessage: TIdMessage
AttachmentEncoding = 'UUE'
BccList = <>
CCList = <>
Encoding = meDefault
FromList = <
item
end>
Recipients = <>
ReplyTo = <>
ConvertPreamble = True
Left = 592
Top = 48
end
This is the code:
procedure TForm11.btnSendClick(Sender: TObject);
begin
IdOpenSSLSetLibPath('C:\Openssl102q'); // Path where is the OpenSSL Library version 1.0.2q
// Setup Host, Username and Password
SMTP.Host := edtHost.Text;
SMTP.Port := 465;
SMTP.Username := edtUsername.Text;
SMTP.Password := edtPassword.Text;
//setup mail message
MailMessage.From.Address := edtFrom.Text;
MailMessage.Recipients.EMailAddresses := edtTo.Text + ',' + edtCC.Text;
MailMessage.Subject := edtSubject.Text;
MailMessage.Body.Text := mmoBody.Text;
if FileExists(edtAttachment.Text) then
TIdAttachmentFile.Create(MailMessage.MessageParts, edtAttachment.Text) ;
//send mail
try
try
SMTP.ConnectTimeout := 1000;
SMTP.Connect;
SMTP.Send(MailMessage);
except
on E:Exception do
ShowMessage(0, 'ERROR: ' + E.Message) ;
end;
finally
if SMTP.Connected then SMTP.Disconnect;
end;
end;
My problems was that I used a very old OpenSSL Library compared to version 1.0.2q.
Regards.