Jump to content
chmichael

TSmtpCli does not send the e-mail ?

Recommended Posts

Hello,

  Any ideas why the below code does not send the email: (it doesn't through an exception either)

 

var
  vSMTP: TSmtpCli;
begin
  vSMTP := TSmtpCli.Create(nil);

  with vSMTP do
  begin
    Host := 'my.mailhost.com';
    Username := 'user@mailhost.com';
    Password := 'password';
    OwnHeaders := True;

    ContentType := smtpPlainText;
    CharSet := 'UTF-8';

    HdrFrom := 'user@mailhost.com';
    HdrTo := 'user@mailhost.com';
    HdrSubject := UTF8Encode('Subject');
    MailMessage.Text := UTF8Encode('Body');

    Connect;

    while State <> smtpReady do
    begin
      ProcessMessages;
      Sleep(50);
    end;

    Mail;
    FreeAndNil(vSMTP);
  end;
end;

 

Thank you

Share this post


Link to post

Calling connect is not enough to send a mail. See the sample program, seen the code behind "all in one" button.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×