Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delphi 10.3 - Enable application to send emails without email client
#2
(04-08-2020, 06:22 PM)joceravolo Wrote: I don't get an error, but the test email does not work.
The message that pops up is Connection close graciously.

That would be an error condition. The server is closing the connection on its end. Basically, it is kicking you out. Usually because you didn't authenticate properly, or the TLS handshake failed.

(04-08-2020, 06:22 PM)joceravolo Wrote: With IdSSLIOHandlerSocketOpenSSL1 do
  begin
    Destination := dbeSMTPServer.Text + ':' + dbeSMTPPort.Text;
    Host := dbeSMTPServer.Text;
    MaxLineAction := maException;
    Port := StrToInt(dbeSMTPPort.Text);

FYI, you don't need to set any of those properties manually, they are set by Connect() for you (well, except for MaxLineAction, but you shouldn't be setting that manually anyway, especially since maException is the default).

(04-08-2020, 06:22 PM)joceravolo Wrote:   IdSMTP.Host := dbeSMTPServer.Text;
  IdSMTP.Port := StrToInt(dbeSMTPPort.Text);

You did not indicate what Host/Port values you are using exactly. It makes a difference, especially in how you have to set the UseTLS property (which you have commented out).

(04-08-2020, 06:22 PM)joceravolo Wrote:   IdSMTP.AuthType := satDefault;

Note that not all SMTP servers will support that setting. satDefault uses an AUTH LOGIN command, which is unsecure without a TLS connection to encrypt it. And even if a given SMTP server does support AUTH LOGIN, not all SMTP servers advertise support for it. You MAY have to set the TIdSMTP.ValidateAuthLoginCapability property to False to get satDefault to actually send its AUTH LOGIN command.

(04-08-2020, 06:22 PM)joceravolo Wrote:   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!');

Rather than using chr(13) (or just #13), you should use the Body.Add() method for each individual line:

Code:
IdMessage.Body.Add('Hi ' + dbeFullName.Text + ',');
IdMessage.Body.Add('');
IdMessage.Body.Add('');
IdMessage.Body.Add('If you received this email, the configuration of the email for the user ' + dbeUsername.Text + ' is correct!');

Or, use the Body.Text property:

Code:
IdMessage.Body.Text := 'Hi ' + dbeFullName.Text + ',' + sLineBreak + sLineBreak + 'If you received this email, the configuration of the email for the user ' + dbeUsername.Text + ' is correct!');

Reply


Messages In This Thread
RE: Delphi 10.3 - Enable application to send emails without email client - by rlebeau - 04-09-2020, 11:15 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)