Smtp with smtp.gmail.com on port 465

Giganews Newsgroups
Subject: Smtp with smtp.gmail.com on port 465
Posted by:  Pibì
Date: Thu, 02 Dec 2010

Indy 10, svn revision 4526. Delphi 2010. openssl-1.0.0a-i386-win32.zip

IdSMTP.Connect hang my application. What's wrong in this code?

Any suggestions would be appreciated.

Paolo

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
  Dialogs, IdMessage, StdCtrls, IdAntiFreezeBase, IdAntiFreeze,
IdIOHandler,
  IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL,
IdBaseComponent,
  IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
  IdMessageClient, IdSMTPBase, IdSMTP;

type
  TForm1 = class(TForm)
    IdSMTP: TIdSMTP;
    IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
    IdAntiFreeze1: TIdAntiFreeze;
    Button1: TButton;
    IdMessage1: TIdMessage;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  IdSMTP.Connect;
  IdSMTP.Send(IdMessage1);
  IdSMTP.Disconnect;
end;

end.

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 284
  ClientWidth = 593
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 288
    Top = 88
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object IdAntiFreeze1: TIdAntiFreeze
    Left = 108
    Top = 33
  end
  object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL
    Destination = 'smtp.gmail.com:465'
    Host = 'smtp.gmail.com'
    MaxLineAction = maException
    Port = 465
    DefaultPort = 0
    SSLOptions.Mode = sslmUnassigned
    SSLOptions.VerifyMode = []
    SSLOptions.VerifyDepth = 0
    Left = 108
    Top = 141
  end
  object IdMessage1: TIdMessage
    AttachmentEncoding = 'UUE'
    BccList = <>
    CCList = <>
    Encoding = meDefault
    FromList = <
      item
        Address = 'myNa…@gmail.com'
        Name = 'myName'
        Text = 'myName <myNa…@gmail.com>'
        Domain = 'gmail.com'
        User = 'myName'
      end>
    From.Address = 'myNa…@gmail.com'
    From.Name = 'myName'
    From.Text = 'myName <myNa…@gmail.com>'
    From.Domain = 'gmail.com'
    From.User = 'myName'
    Recipients = <
      item
        Address = 'myNa…@gmail.com'
        Text = 'myNa…@gmail.com'
        Domain = 'gmail.com'
        User = 'myName'
      end>
    ReplyTo = <>
    ConvertPreamble = True
    Left = 108
    Top = 88
  end
  object IdSMTP: TIdSMTP
    IOHandler = IdSSLIOHandlerSocketOpenSSL1
    PipeLine = True
    Host = 'smtp.gmail.com'
    Password = 'myPassword'
    Port = 465
    SASLMechanisms = <>
    Username = 'myNa…@gmail.com'
    Left = 108
    Top = 201
  end
end

Replies