Atozed Forums

Full Version: Setting TidSMTP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
  I have this setting on Thunderbird for smtp account:

authentication method = Encrypted Password
connection security = SSL/TLS

What settings I do in TidSMTP to make the same settings?

Thanks
Waiting for message moderation, I found the settings:
SMTP.UseTLS := utUseImplicitTLS;
SMTP.IOHandler.SSLOptions.Method := sslvTLSv1_2;

With this settings and all other defaults of SMTP/IOHandler I can send emails but if I try to send email by a SMTP server with this configuring in Thunderbird:
Authentication method = Normal Password
Connection security = SSL/TLS

I always have this error on SMTP.Connect:
"ERROR: Socket Error # 10054 Connection reset by peer."


What is the corrispondig Thunderbird Authentication method = "Normal Password" in idSMTP component?

Thanks

Seems I found the trouble. I used a very old OpenSSL library, using OpenSSL library 1.1.0.2q I solved Smile

Thanks.
(10-25-2020, 04:19 PM)luigisic Wrote: [ -> ]Waiting for message moderation, I found the settings:
SMTP.UseTLS := utUseImplicitTLS;
SMTP.IOHandler.SSLOptions.Method := sslvTLSv1_2;

With this settings and all other defaults of SMTP/IOHandler I can send emails but if I try to send email by a SMTP server with this configuring in Thunderbird:
Authentication method = Normal Password
Connection security = SSL/TLS

I always have this error on SMTP.Connect:
"ERROR: Socket Error # 10054 Connection reset by peer."


What is the corrispondig Thunderbird Authentication method = "Normal Password" in idSMTP component?

Thanks

Seems I found the trouble. I used a very old OpenSSL library, using OpenSSL library 1.1.0.2q I solved Smile

Thanks.

Hi, I am also trying to setup IdSMTP to send email. Could you share the settings of your setup?
Thanks.
(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.
(01-07-2021, 04:06 PM)luigisic Wrote: [ -> ]Port = 465
UseTLS = utUseImplicitTLS

Just as an FYI, use utUseImplicitTLS only on port 465. For ports 25 and 587, use utUseExplicitTLS instead.

(01-07-2021, 04:06 PM)luigisic Wrote: [ -> ]SSLOptions.SSLVersions = [sslvSSLv2, sslvSSLv3, sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]

SSL v2.0 and v3.0 are no longer secure, and thus nobody uses them anymore, so you should not be enabling them at all:

Code:
SSLOptions.SSLVersions = [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]

And be aware that many servers nowadays are phasing out TLS v1.0 and even v1.1, too.

(01-07-2021, 04:06 PM)luigisic Wrote: [ -> ]
Code:
IdOpenSSLSetLibPath('C:\Openssl102q'); // Path where is the OpenSSL Library version 1.0.2q

You should be calling that only 1 time, such as at program startup.

(01-07-2021, 04:06 PM)luigisic Wrote: [ -> ]
Code:
// Setup Host, Username and Password
SMTP.Host := edtHost.Text;
SMTP.Port := 465;

Note that not all servers use port 465.

(01-07-2021, 04:06 PM)luigisic Wrote: [ -> ]
Code:
MailMessage.Recipients.EMailAddresses := edtTo.Text + ',' + edtCC.Text;

CC recipients should be assigned to the TIdMessage.CCList property instead:

Code:
MailMessage.Recipients.EMailAddresses := edtTo.Text;
MailMessage.CCList.EMailAddresses := edtCC.Text;
Thanks for the tips.
(01-07-2021, 06:15 PM)luigisic Wrote: [ -> ]Thanks for the tips.

Thanks for sharing.
I am using a TIdMessageBuilderHTML object to construct TIdMessage object.
For the OpenSSL lib, I am using the latest ones from Fulgan/SSL directory.
Sorry, if I don't post any code here... The code is too scattered in different procs Big Grin