Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delphi 10.3 - Enable application to send emails without email client
#1
Hi,

I want to make an application send different emails using tidSMTP.
The tests I am doing using Yahoo or Gmail to send the email it not working but I don't know why.
I don't get an error, but the test email does not work.
The message that pops up is Connection close graciously.
I am new to this and I haven't found any documentation on how to approach this.

Thanks in advance,

Here's the code:

With IdSSLIOHandlerSocketOpenSSL1 do
  begin
    Destination := dbeSMTPServer.Text + ':' + dbeSMTPPort.Text;
    Host := dbeSMTPServer.Text;
    MaxLineAction := maException;
    Port := StrToInt(dbeSMTPPort.Text);
    SSLOptions.Method := sslvTLSv1;
    SSLOptions.Mode := sslmUnassigned;
    SSLOptions.VerifyMode := [];
    SSLOptions.VerifyDepth := 0;
  end;
//SETTING SMTP COMPONENT DATA //
  IdSMTP.Host := dbeSMTPServer.Text;
  IdSMTP.Port := StrToInt(dbeSMTPPort.Text);
  IdSMTP.Username := dbeSMTPUser.Text;
  IdSMTP.Password := dbeSMTPPassword.Text;
  IdSMTP.IOHandler := IdSSLIOHandlerSocketOpenSSL1;
  IdSMTP.AuthType := satDefault;
  //IdSMTP.UseTLS := utUseExplicitTLS;
// SETTING email MESSAGE DATA //
  IdMessage.Clear;
// add recipient list //
  with IdMessage.Recipients.Add do
  begin
    Name := dbeFullName.Text;
    Address := dbeEmail.Text;
  end;
  IdMessage.From.Address :=  dbeEmail.Text;
  IdMessage.Subject := 'Email Test From Sales Manager';
  IdMessage.Body.Add('Hi ' + dbeFullName.Text + ',' + chr(13) + chr(13) +
                    'If you received this email, the configuration of the email for the user ' + dbeUsername.Text +
                    ' is correct!');
  IdMessage.Priority := mpHigh;
  try
    IdSMTP.Connect();
    IdSMTP.Send(IdMessage);
    ShowMessage('Email sent');
    IdSMTP.Disconnect();
  except on e:Exception do
    begin
      ShowMessage(e.Message);
      IdSMTP.Disconnect();
    end;
  end;
Reply


Messages In This Thread
Delphi 10.3 - Enable application to send emails without email client - by joceravolo - 04-08-2020, 06:22 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)