Delphi 2007, IdSMTP and google mail

Giganews Newsgroups
Subject: Delphi 2007, IdSMTP and google mail
Posted by:  fabio codebue @ gestionaleopen (fabio.codeb…@gestionaleopen.org)
Date: Tue, 28 Apr 2009

I'trying to send email use this code.

var
  v_da, v_a, v_acc, v_abcc: TIdEMailAddressItem;
  v_mail: TIdMessage;
begin
    v_status.Lines.Clear;

    //setup SMTP
    IdSMTP.Host:= v_smtp_server.Text;
    IdSMTP.Port:= strtoint(v_smtp_porta.text);
    IdSMTP.Username:= v_smtp_utente.Text;
    IdSMTP.Password:= v_smtp_pwd.Text;

    IdSSLIOHandlerSocketOpenSSL.Destination:= v_smtp_server.Text;
    IdSSLIOHandlerSocketOpenSSL.Port:= strtoint(v_smtp_porta.Text);
    IdSMTP.IOHandler:= IdSSLIOHandlerSocketOpenSSL;

  //  IdSMTP.SASLMechanisms:= ;
    IdSMTP.UseTLS:= utNoTLSSupport;

    // SASL
    IdSMTP.AuthType:= atSASL;
    IdUserPassProvider.Username:= v_mittente.Text;
    IdUserPassProvider.Password:= v_mittente_pwd.text;

    //setup mail message
    v_mail:= TIdMessage.Create(nil);
    v_mail.Recipients.EMailAddresses:= v_destinatario.Text;
    v_mail.From.Address:= v_smtp_utente.Text;
    v_mail.From.Name:= v_mittente.Text;
    v_mail.From.Text:= v_mittente.Text;
    v_mail.From.DisplayName:= v_mittente.Text;

    v_mail.ReplyTo.EMailAddresses := v_smtp_utente.Text;
    v_mail.Subject := v_soggetto.Text;
    v_mail.Body.Add(v_testo_mail.Lines.Text);

    v_mail.Priority:= mpHighest;

    //send mail
    try
      try
        IdSMTP.Connect ;
        if IdSMTP.Authenticate then
          IdSMTP.Send(v_mail)
        else
          v_status.Lines.Insert(0, 'ERROR: Autentificazione non
avvenuta!' );
      except on E:Exception do
        v_status.Lines.Insert(0, 'ERROR: ' + E.Message) ;
      end;
    finally
      if IdSMTP.Connected then IdSMTP.Disconnect;
    end;
end;

but after IdSMTP.Connect I have back message connected and wait forever...

I try to change  IdSMTP.AuthType with atSASL, atDefault... I try to send
to standard pop3 server without problems...

any idea?

fabio

Replies